VS2010 - publish website, empty folders are ignored - visual-studio-2010

In visual studio 2010, when publishing a website, it seems that empty folders are not being published.
I am quite sure that this behavior were introduced in vs2010. I cant find it documented anywhere, not sure if I should call it a feature or a bug... Anyway, is it possible to revert to the old behavior as I wish to keep my folder structure on the production server.

This is actually a limitation of vs2010 as reported on the Microsoft connect site
http://vishaljoshi.blogspot.com/2007/11/wdp-does-not-publish-empty-folders.html
http://connect.microsoft.com/VisualStudio/feedback/details/546356/publish-deploy-does-not-deploy-empty-folders

There was a bug report to Microsoft about this and they said that they would not fix it.
http://connect.microsoft.com/VisualStudio/feedback/details/546356/publish-deploy-does-not-deploy-empty-folders
Too bad. Because it used to work in Visual Studio 2008.
Add a dummy file like dummy.txt to the directory and then the directory will be created.
Note that it is not necessary to actually deploy the dummy file. It only needs to exist as part of the project in the build environment.

The Empty folder doesn't have any memory value so if you want to add your folder's into your published folder then simply add any item(e.g. text File) into it and set the "Copy to output directory" = Copy always or Copy if Newer this will resolve you problem

Related

"The project file was unloaded" when moving VS2010 project to another server

I have moved a Visual Studio 2010 project to another server by copying and pasting the folder contents into another folder on a different server.
My understand was that VS2010 handled this well; when I have done this locally it has never been an issue.
Now I get an error like this:
When I right click and "Reload project", the list of files briefly appears before disappearing again, giving the original error.
Am I doing something wrong?
I experienced the same problem today. Here is what I did and worked for me :
Open the .sln file.
Right click on the project folder and click Reload project.
You will see the projects and folders that you originally had.
You will see .xml publish file . Double click it .. You should be good to go now.
I had this problem today and it took me a while to figure out what was going on.
Your problem is most likely that your solution was originally made with a Visual Studio configuration that contained support for certain project types (such as "Windows Service" or some other exotic project type). The Visual Studio configuration you are using to import your solution does not have that support. In other words,
there is probably nothing wrong with your solution,
there is probably nothing wrong with your project,
there is probably nothing wrong with any of the files (as you mentioned they do display briefly, giving you a second of hope)
Just run the installer on the new Visual Studio and make sure the support is enabled for all the project types you need and try again.
In my case the problem was the .vbproj file had somehow been corrupted so the normal xml code was replaced with a long string of null characters. I noticed this thanks to a file that was generated in the same folder as the project file when I tried to open the project - it was called 'UpgradeLog.htm'. This had an entry saying ' Error on line 1. Expected '<' but found 'null character'.'.. suggests there may have been a recent update to Visual Studio that I hadn't noticed?
Luckily I could use my source control system to revert back to a slightly earlier version - I guess it shows how important it is to have backups!
In my case, I saw similar message (Projected was unloaded) and all I had to do was simply re-launching Visual Studio (2017) in Admin mode and the problem went away. Per one of the above answers, I tried to right-click and selected Reload but got a warning that, due to required access to IIS on the machine, I had to launch VS in Admin mode.
HTH
Found this answer and it worked for me.
Note:Sometimes, the path in File path property is grayed out and you are unable to get to the Browse button. In this case try deleting .suo files. Don’t worry, these files gets recreated when you rebuild the solution / project.
http://www.howtosolutions.net/2013/02/solving-project-file-error-could-not-find-part-of-the-path-with-visual-studio/
I had the same problem. I fix path to .csproj files in the .sln file with a text editor and now it is all ok.
Open Visual Studio as Administrator

Publish content of referenced project

Using Visual Studio 2013 (but I have this problem in 2010, and 2012) I wanted to give click-once a go and see if it was worth my troubles. I think it could be, but I'm not 100% sure yet. I created a new wpf project called PublishClickOnceTest and then added an existing project to the solution. The existing project has a DLL that is marked as Content. I put a text block in my application to see if the dll was present. That dll is required for the referenced project of mine to work. On my development PC it comes back as true, but when I install it on my tablet it says false. I've searched around and everyone says mark it as content.. well it is. So I'm not sure why it isn't grabbing this content file. Does anyone know how to make it do this?
In Visual Studio 2013, you should find that items marked with the build action set to content are included by default:
Files with the Build Action property set to Content are designated as
application files and will be marked as included by default. They can
be included, excluded, or marked as data files.
However, in older versions you used to have to set it to Copy Always. To do this you can use the property viewer of the item in your Solution Explorer, then you set Copy to output directory to Copy Always.

Error MSB3541: Files has invalid value

I just deployed an asp.net mvc 3 web application to AppHarbor but it failed:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3932,5): error MSB3541: Files has invalid value "<<<<<<< HEAD". Illegal characters in path. [D:\temp\q5cmde4m.uk1\input\MyProject\MyProject.csproj]
This happened after I opened the project with Visual Studio 2012 (the application was created with VS2010).
Try to search the entire solution for the value and remove it from where it occurs, and then delete the obj folder from your project. When you build again it should work.
The obj folders are hidden in Visual Studio. You can see them with a file explorer.
Delete the obj folder within your project and it will fix the issue.
though it is very old question but I would like to add an answer here.
when you work with multiple developer in visual studio you should git ignore obj folder, .suo,.sln etc which is only holding the visual studio information user based.
refer to this SO question
Ok this might be helpful to someone else.
in my case my .vbproj file and some form files somehow had the last lines of its code truncated, I fixed this by restoring this missing part of the code (around the last 10 lines were missing) from a previous backup of the same project.
The other files got corrupted in a simillar way and were fixed by restoring the missing parts of the files from the backed up ones on a text editor (notepad)
After getting this the project loaded without issue.
Delete both obj and bin folder it will fix the issue, which in my cas its been done and it was causing when create pull request from remote repository !!
Yes, it is about merging conflicts. Usually Visual Studio highlights most of the errors with file paths. However, it does miss some files.
All you have to do is REMOVE the "obj" an "bin" folder from your solution.
If you are in Visual Studio, you have to select "Show All/Hidden files" as "obj" folder is hidden, and then delete it.
You can also delete it by going to your directory where your project is stored e.g C:/Users/username/source/repos/project/ (can be different in your case).

Opening a Visual Studio 2010 project in 2012 what creates the backup folder and how to control it?

I have an issue. We are upgrading to VS 2012 at work. When we open a VS 2010 project Visual Studio converts the project. This is fine, because VS 2010 can still use the project (yay microsoft). However, there is a \Backup folder created in the solution directory. Is this being created as part of the migration? Is there any way to control it?
The reason I ask is that the process that makes this folder copies web.config files into the folder. If you then try to build the solution (these are MVC projects), we get a "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS." error. The cause is that there is a web.config file in a subfolder instead of the root folder. We did not make and do not want this change, and cannot figure out how to control it. Deleting the Backup\Web.config file fixes the error. Renaming it from web.config to web.config.bak fixes the problem.
I don't really want to have to personally open and convert every single project, and don't want random people bumping into this problem. Any idea how to either stop VS from creating the Backup folder, or how to make it create them in the my documents studio folder etc? I can't find any setting to control this and can't find any good info.
By chance, are you using the MvcBuildViews property to pre-compile your views at build time? If so, this is why you're encountering this (since it does the pre-compile in the same directory, it doesn't filter out any of the files below the project directory).
Note that you will also encounter this issue if you use the Publish feature for this project. Publish copies the web.config under your intermediate build output directory (by default, obj/) before and after applying web.config transforms.
The good news is that in VS2012, or in VS2010 with the latest Azure SDK installed, pre-compile is now supported for Web Application Projects (including MVC). These settings are currently in the project properties, under the Package/Publish Web tab.
(this doesn't directly address your question about the Backup folder, but it was too long for a comment.)
There is no way to control it that I found. We had to go ahead and run through and convert every project to 2012 and delete the backup folders to prevent any other team from running into it.

Recover a .CS class file after crash

I was working on a class in visual studio 2010 when suddenly my computer crashes. after I restart the computer. I start Visual studio and I find that class to be completely empty.
it contained more than 1000 lines of codes before the class.
is there anyway i can recover that file?
Help please because I don't have another copy of it (Stupid of me)
If you cannot find the source code file, try using Reflector to decompile the most recently built dll you have containing that class. It won't give you your complete source, but at least will give you something to start with.
Note: Reflector is no longer free; if that matters, try dotPeek from JetBrains instead.
Also, look into using a source code control system. This will let you 'commit' versions of your code to a repository, so you'll have a copy in case something like this happens in the future.
Subversion, Git, and Mercurial are popular ones; In my opinion, Subversion would be the easiest to start out with, especially with TortoiseSVN (OS integration) and AnkhSVN (Visual Studio integration). If you don't want to worry about setting up a repository/server, look into a hosted solution, like Beanstalk, which offers Subversion and Git and lets you try it out with a free, limited account.
Good luck - I hope you are able to recover your source!
Something which worked for me was back-up.
BTW I was trying to recover a VS2013 file on a Windows 8 machine.
Try to check in below location in your system.
C:\Users\username\My Documents\Visual Studio \Backup Files\ProjectFolder
I found an original file with original-date.filename.cs name and a recovered-date.filename.cs files.
The original was the one needed.
Deleted the one in project, added the original file and renamed it to file.cs. Tried building and debugging and it gave the expected results.
Also just want to add one more thing...
In my case i had an aspx page with its respective .cs and designer.cs
The .cs file got corrupted and I did build on project, with the designer.cs the project got build successfully and the dll got replaced. And when i tried to recover using reflector everything was in a state no return. :(
So don't build the project if you see any file got corrupted.
in visual studio 2019 I find the file in a files with TMP extension
FileName.cs~xxxxxxxx.TMP
This happened to me a few times as well when Visual Studio was crashed or System was shutdown unexpectedly.You can recover these corrupted file using Recuva. It dose not recover the file every time but in most of the cases it's work perfectly.
Below are the settings which you need to configure before recovery.
Start Recuva. Enter Advanced mode if the Wizard launches.
Click Options.
In the Options dialog box, click the Actions tab.
Click Scan for non-deleted files, and then click OK.
Run the Recuva scan as normal. Non-deleted files are indicated with a green double-circle status icon.
Hopefully, you will find your corrupted file in recovered files as it recover multiple versions for that file.
Very useful question. I got issue of file crash on sudden shutdown of my PC. recovered file using "Recuva"(download link: https://filehippo.com/download_recuva/) software. Scan for non-deleted files was helpful.
I got help from: https://www.samnoble.co.uk/2014/11/30/visual-studio-crashes-and-a-corrupted-cs-file/
Well, that happen recently for me and I did get my file back this way.
1. Find the project DLLs in the bin folder. Example MySolution.dll
2. Download and Install .Net Reflector from https://www.red-gate.com/products/dotnet-development/reflector/trial/thank-you
3. Open the .Net Reflector app and click the open folder icon then move to your bin directory and select MySolution.dll file
4. Then traverse and expand through your namespaces and classes to look into your codes.
5. Have fun!

Resources