[asp.net] Visual Studio 2012 Web Publish doesn't copy files

I have a Web Application project in VS 2012 and when I use the web publishing tool it builds successfully but doesn't copy any files to the publish target (File System in this case).

If I look at the build output I can see everything gets copied over to obj\Release\Package\PackageTmp\ correctly but then all I see in the build output is this:

4>Done building project "{Project}.csproj".
4>Deleting existing files...
4>Publishing folder /...
4> ========== Build: 3 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

Even though it says the publish succeeded there are not files in the target directory for the publish.

I have seen this in multiple projects and sometimes it seems like the Solution/Platform configurations cause this problem but I haven't been able to pinpoint an exact cause for this.

Has anyone else seen this happening or have an idea on how to get this working correctly?

UPDATE:

I may have found a workaround for this. I just had this happen again and I was messing around with the publish settings. Once I changed the selected Configuration on the Settings tab away to another configuration and then back to the one I wanted to use all my files started publishing again. Hopefully this works on other projects in the future.

UPDATE 2:

I posted a bug on Microsoft Connect and heard back from a developer on the VS Web Developer team. He said they have fixed this issue in their internal builds and will releasing an update to the publish tool soon that will fix this problem.

UPDATE 3:

This has been recently fixed with Visual Studio 2012 Update 2

The answer is


Follow these steps to resolve:

Build > Publish > Profile > New

Create a new profile and configure it with the same settings as your existing profile.

The project will now publish correctly. This often occurs as a result of a source-controlled publish profile from another machine that was created in a newer version of Visual Studio.


Try quitting Visual Studio, delete the relevant pubxml.user file in your PublishProfiles directory, restart VS and publish. Worked on VS 2019.


I had published the website several times. But one day when I modified some aspx file and then tried to publish the website, it resulted in an empty published folder.

On my workaround, I found a solution.

  1. The publishing wizard will reflect any error while publishing but will not copy any file to the destination folder.

  2. To find out the file that generates the error just copy the website folder contents to a new folder and start the visual studio with that website.

  3. Now when you try to publish it will give you the file name that contains errors.

  4. Just rectify the error in the original website folder and try to publish, it will work as it was earlier.


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've got into same problem. None of the above solutions worked for me.

So, I've excluded the files which failed to copy while publishing.


In Visual Studio 2012, switching between releases still causes problems.

We added a pre-build event to delete the obj folder: del /s /f /q $(ProjectDir)\obj and it fixed the issue of publishing. Cleaning works sometimes, but not always.


I ran into the same problem on VS 2010, after checking publish output, event logs, turning on and checking visual studio logs etc I then decided to remove the web publish (via add/remove) which I believe had been recently updated to v1.0.30810.0. This resolved the problem.


I encountered this with Visual Studio generated Service Reference files becoming too long in terms of the overall path length.

Shortened them by re-generating the Service Reference using svcutil.exe, deleting all the original Service Reference files.

svcutil can be called like this:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\SvcUtil.exe" /language:CS http://myservice /namespace:*,My.Namespace

My.Namespace should be replaced with the existing namespace in the generated service proxy (typically found in the Reference.cs file) to avoid compilation errors.

http://myservice should be replaced with the service endpoint url.


I finally found the answer by myself. All of the above solutions doesnt work for me.

What i had done is that i move the project to drive c change the project folder to something shorter and boom it publish..

the reason that it failed on my side is that i had very long project name/heirarchy.

C:\Users\user\Desktop\Compliance Management System\ComplianceIssueManagementSystem\ComplianceIssueManagementSystem

I had thought of this because sometimes when i extracted rar file it says that the name/path is too long. I thought it will be the same as visual studio 2012 publish. and it does!

hope it will help you guys.


My problem was in wrong configuration of myproject.csproj file. '_address-step1-stored.cshtml' file did not copy on publish. 'None' changed to 'Content', now it's ok. enter image description here


None of the above solutions worked for me.

But I noticed that of our five ASP.NET MVC projects in our main solution, four of them put the deployment package in the right place, while one left it under obj\Debug.

I compared the projects and found a discrepancy. The solution was to change this:

<Import
    Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

to this:

<Import
  Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets"
  Condition="'$(VSToolsPath)' != ''" />
<Import
  Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"
  Condition="false" />

After I made this change, all five projects put their deployment packages in the right spot.

(Sorry about the long lines, but I couldn't find a better way to condense them.)


I found the I could get around this problem by changing the target location from obj/[release|stage|..] to a new path outside of the solution folders completely eg c:\deployment. It seems like VS 2012 was getting confused and maybe giving up somewhere during the publish process.

Matt


Had the same problem recently in VS 2013 for a MVC project in which I imported Umbraco CMS. I couldn't publish. The answer above helped, though I needed a while to figure out what I actually should do in VS. It needed some research e.g. on MS blogs to find out. I try to say it simple:

  • Choose in the VS toolbar a certain configuration e.g. Release and Any CPU. Run the project.
  • Afterwards right-click in the Solution Explorer on the solution in question, choose Publish. Create a new publishing profile or use a given one, but always make sure that in the settings the same configuration (e.g. Release and Any CPU) is chosen, as before you run the project the last time.
  • Additionally in my case it was necessary to delete the OBJ folder because here the settings from my last unsuccessful tries to publish got stuck, though I restarted VS and deleting all publishing profiles.

FIXED - various solutions offered didn't work for me. What did work for me with VS Community 2017, Windows Server 2012 R2 was to change the TEMP and TMP environmental variables for the user and then restart the system and deploy again (restarting VS was not enough). These temp variables are where VS does the temp publish.

enter image description here

enter image description here

enter image description here

Restarting visual studio after changing temp variables didn't do the trick, had to reboot system.


Check your current project that whether you have made back copy with same class name and different page name (Class name will inherit copied file). Ultimately that will confuse the compiler!!!

CodeFile="Consolidated.aspx.vb" Inherits="Consolidated


I have a Web Application with several other referenced Projects in the Solution. I've deployed successfully with a single Publish configuration many times in the past. I changed the Project Configuration from Debug to Release for a Project that had been missed in the past. The next time I attempted to deploy I got these symptoms, where the Publish just quietly fails - it does nothing and says it succeeded:

1>------ Build started: Project: Project, Configuration: DeployProduction Any CPU ------
1>  
2>Publishing folder /...
========== Build: 1 succeeded, 0 failed, 9 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

The only way to recover it was to wipe out the Publish profile, close Visual Studio to force it to save the deletion, reopen it, and recreate the Publish profile from scratch. Once I did that I could Publish fine again.

Win8 VS2012, crappy laptop.


For what it's worth, I eventually gave up on fighting with Web Deploy to get it to do what I wanted (copy deployable files and nothing else), so I scripted it in PowerShell and am really happy with the result. It's much faster than anything I tried through MSBuild/Web Publish, presumably because those methods were still doing things I didn't need.

Here's the gist (literally):

function copy-deployable-web-files($proj_path, $deploy_dir) {
  # copy files where Build Action = "Content" 
  $proj_dir = split-path -parent $proj_path
  [xml]$xml = get-content $proj_path
  $xml.Project.ItemGroup | % { $_.Content } | % { $_.Include } | ? { $_ } | % {
    $from = "$proj_dir\$_"
    $to = split-path -parent "$deploy_dir\$_"
    if (!(test-path $to)) { md $to }
    cp $from $to
  }

  # copy everything in bin
  cp "$proj_dir\bin" $deploy_dir -recurse
}

In my case I'm calling this in a CI environment (TeamCity), but it could easily be hooked into a post-build event as well.


Same problem with VS 2012 Pro with a disk publish target. Project used to publish correctly but started doing this issue where it failed to copy the files to the destination folder.

Solution was to edit the publish profile, change the mode from Release (Any CPU) to debug then back to Release (Any CPU). Doing this causes the PublishProfiles\projname.pubxml.user file to be rewritten (as described above). Looks like it added the LastUsedBuild,LastUsedPlatform and TimeStampOfAssociatedLegacyPublishXmlFile elements under the propertygroup node. After the publish is complete, it adds another ItemGroup with individual files and publish times.


The easiest is,

   1. select the file(s) that are not being copied,
   2. Press <F4> to get the properties window
   3. Make the "Build Action" property "compile" or "content" depending on what it is.
   4. Now this particular file will be included!

The following worked for me:

Simply change from Release>Debug>Release (or vice-versa) and then publish.

No need for deleting, editing, publishing anything you don't need to.


I tried all of these solutions but this is the one that works every time.

We just change the "Publish method:" from "File System" to for example "Web Deploy", and immediately change it back to "File System".


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


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.


First:

  • Build in release Configuration.
  • In Project Properties-> page select All files and folders under Package/Publish Web.
  • Rebuild solution (after Clean solution).
  • now publish.

While publishing recheck what u have opted.
this should do it. It did for me!:)


This action was successful for me:

Kill Publish Profiles in "Properties>PublishProfiles>xxxx.pubxml" and re-setting again.


Here we had the same problem.

We just change the "Publish method:" from "File System" to for example "Web Deploy", and immediately change it back to "File System".


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.


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.


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


I have (had) the same problem for several projects. The only ones hit seem to be web projects. Deleting and recreating the profile solves the problem only once. Additionaly, comparing the publishxml generated yields no differences, so it does not seem related to the profile at all.

The workaround mentioned by OP to change build problems back and forth seems the only reliable solution at this time.


Examples related to asp.net

RegisterStartupScript from code behind not working when Update Panel is used You must add a reference to assembly 'netstandard, Version=2.0.0.0 No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization How to use log4net in Asp.net core 2.0 Visual Studio 2017 error: Unable to start program, An operation is not legal in the current state How to create roles in ASP.NET Core and assign them to users? How to handle Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause() ASP.NET Core Web API Authentication Could not load file or assembly 'CrystalDecisions.ReportAppServer.CommLayer, Version=13.0.2000.0 WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jquery

Examples related to asp.net-mvc

Using Lato fonts in my css (@font-face) Better solution without exluding fields from Binding Vue.js get selected option on @change You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to send json data in POST request using C# VS 2017 Metadata file '.dll could not be found The default XML namespace of the project must be the MSBuild XML namespace How to create roles in ASP.NET Core and assign them to users? The model item passed into the dictionary is of type .. but this dictionary requires a model item of type How to use npm with ASP.NET Core

Examples related to visual-studio-2012

How to actually search all files in Visual Studio Tests not running in Test Explorer How to use _CRT_SECURE_NO_WARNINGS Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0 How can I resolve the error: "The command [...] exited with code 1"? Could not load file or assembly Exception from HRESULT: 0x80131040 MSVCP120d.dll missing How can I change IIS Express port for a site The program can't start because MSVCR110.dll is missing from your computer Controlling execution order of unit tests in Visual Studio

Examples related to msbuild-wpp

Visual Studio 2012 Web Publish doesn't copy files

Examples related to visual-studio-publish

Visual Studio 2012 Web Publish doesn't copy files