Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2012 Web Publish doesn't copy files

People also ask

How do I change publish settings in Visual Studio?

On the computer where you have the ASP.NET project open in Visual Studio, right-click the project in Solution Explorer, and choose Publish. If you have previously configured any publishing profiles, the Publish pane appears. Click New or Create new profile.

What is the difference between build and publish in Visual Studio?

Build compiles the source code into a (hopefully) runnable application. Publish takes the results of the build, along with any needed third-party libraries and puts it somewhere for other people to run it.

How do I publish an entire solution in Visual Studio?

To publish your app from Visual Studio, do the following: Change the solution configuration from Debug to Release on the toolbar to build a Release (rather than a Debug) version of your app. Right-click on the project (not the solution) in Solution Explorer and select Publish. In the Publish tab, select Publish.


Same problem. The workaround was changing the publish settings from Release to Debug. Re-publish and then change back to Release...


This may be caused by solutions/projects that were created with the RC of vs2012. This happened to me months ago and fixed the problem by making sure my solution build configurations matched my project configurations...

I just recently experienced the same problem when opening the same solution originally created in vs2012RC with VS2012 Express for Web. I did exactly what the original poster suggested and it fixed my problem.

Here is the thread that lead me to the answer:

connect.microsoft.com/VisualStudio/feedback/details/746321/publish-web-application-fails

The pertinent response from the conversation above that helped me was:

Posted by Microsoft on 6/13/2012 at 12:00 PM Hi Andrew,

This was a bug in how we handle the solution configuration vs. the project configuration. We incorrectly assumed that they would be the same (e.g. Solution's Release|x86 would have each project set to Release|x86 as well), which caused us to use the wrong build properties for publishing files.

The workaround is to make the solution configuration and build configuration match. This issue will be fixed in the next release of Visual Studio 2012.

Thanks, - Jimmy Lewis SDET, Visual Web Developer team


To take this a bit further. You have two files that are created when you create a publish profile.

  • NewProfile.pubxml
  • NewProfile.pubxml.user

When you open a project that has these files in the PublishProfile folder from a source control it only has the .pubxml file and not the .publxml.user file, so it creates the .publxml.user file on the fly when you open the project. When it creates the new .publxml.user on the fly the xml looks like:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

When you create a new profile it creates xml that looks like:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <TimeStampOfAssociatedLegacyPublishXmlFile />
    <EncryptedPassword />
  </PropertyGroup>
</Project>

If you take the <PropertyGroup> node and put it in the .pubxml.user file your PublishProfiles will start working again.


An easy fix is to delete your publish profile and create a fresh one.

when you right click on your solution and select publish, you have a profile set. delete this and create a new one.

this will fix it.

I had this problem from switching from 2010 to 2012


I had same error and I change the setting from release to debug and the problem resolved..


I had this same problem however none of the answers in this thread worked for me. My issue was that there is a directory that contains dynamically generated (by my app) static HTML files. The entire directory was not being published.

The solution that worked for me was found here:

One issue I got a while back and thought I should document was that certain file types were not being uploaded when I published my project.

The file types in question were .pdf files and .rtf.

The reason this happened was because these file extensions were not recognized as requiring publishing by Visual Studio. Luckily this can be changed in Visual Studio.

Select the file(s) that aren’t being copied. In Properties ensure that Build Action is set to Content.

If this doesn’t work the following can be tried.

Under the Project menu select Package/Publish Web and notice this drop down:

enter image description here

Try changing this to All files in this project folder.


This is because the .pubxml.user contains required information to publish, and that file isn't (and shouldn't) be included in source control. To fix this VS bug, copy the information from the .pubxml.user file to the .pubxml file. The relevant properties are:

<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>

Put those in your .pubxml and you should be good to go.