232

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

Roman Pokrovskij
  • 9,449
  • 21
  • 87
  • 142
Jeff Papp
  • 2,443
  • 2
  • 16
  • 11
  • 1
    That is weird. If you see Publishing folder /... , it should work correctly. I suggest you check with your path. Make sure you are looking at the right place. – maxisam Aug 30 '12 at 16:15
  • Looks like it's working now. Maybe Restarting VS did the trick. This is what I'm seeing now: `2>Done building project "{Project}.csproj".` `2>Deleting existing files...` `2>Publishing folder /...` `2>Publishing folder bin...` `2>Publishing folder Controls...` `2>Publishing folder ExternalReferences...` – Jeff Papp Aug 30 '12 at 20:17
  • 1
    I have the same problem, and restarting Visual Studio is not helping :( – Antoine Aubry Aug 31 '12 at 09:29
  • 14
    This happened to me on Windows 8 with Visual Studio 2012. I just now created a new publishing profile and it works! Probably a bug in VS 2012. :/ – T.Ho Aug 31 '12 at 21:03
  • @yzorg I've had this issue on a few machine one, does have an SSD but the others are just normal hard drives. – Jeff Papp Sep 05 '12 at 17:25
  • I'm also having this problem on two machines, both are Windows 8, one with SSD, other one is HDD. The project is a MVC 3 project, upgraded from VS 2010. – Alper Sep 11 '12 at 18:46
  • 1
    Having a similar problem, except in my case it's publishing only files from the main project (and not anything built from other included projects). It looks like I can "publish selection" on the other projects, which are just class libraries, but it would require me to create profiles for each of them. This seems ridiculous and not right. So far am just switching back to VS2010 to publish, where everything works fine. – Jamie Treworgy Sep 11 '12 at 21:20
  • 3
    I had the same problem. Deleting and recreating the publishing profile did the trick for me. – Tommy Jakobsen Sep 12 '12 at 06:23
  • Can you link to the connect issue? I'd like to upvote it. This appears to be an intermittent problem, solved as you noted by simply modifying the publish configuration settings. – NotMe Feb 06 '13 at 23:11
  • Here's the link to the connect issue. https://connect.microsoft.com/VisualStudio/feedback/details/761294/web-publish-doesnt-copy-files – Jeff Papp Feb 07 '13 at 16:23
  • 3
    Deleteing and recreating profiles did the trick for me. – Michael Wells Feb 08 '13 at 16:01
  • 1
    In my case changing the configuration in settings and set it back again did the trick. – VahidNaderi Feb 28 '13 at 23:34
  • 1
    Switching between Debug and Release forth and back doesn't help in my case. Neither does creating a new profile. Neither does deleting all publishing profiles phyiscally. Neither does re-opening the solution or visual studio. As of now (VS 2012 Upd. 3) this issue has NOT been fixed. VS publish fails me on a regular basis. – lapsus Sep 27 '13 at 10:41
  • @lapsus What kind of messages do you get in your output window? Do you actually get a publish failure or just not copying the files? – Jeff Papp Oct 03 '13 at 22:51
  • No failure per se but a failure to publish properly for sure. It says 23>Publishing folder /... and nothing more afterwards although there should be way more - and not even the root folder data was copied. In the meantime I got it running - the question if for how long. I believe the decisive piece of the puzzle was to apply the same build configuration to every project (e.g. Debug, Any CPU). – lapsus Oct 07 '13 at 11:36
  • 3
    This has not been fixed in Visual Studio Update 2, nor in the Update 3. Check the most popular answer after the "accepted answer" (which is not the solution). Just edit the profile and -in the "Settings" tab- select the correct configuration from the list (if release is the good one, select debug, save, then edit again and select release). Save and publish. – firepol Oct 24 '13 at 12:21
  • I still encounter this issue in SP4 from time to time too. – axawire Mar 18 '14 at 18:28
  • I had the same problem and installed VS 2012 Update 4 and now it works. – Paul Apr 25 '14 at 01:47
  • Had the same issue with Visual Studio 2013 Update 4, when using function "Publish..." and RELEASE build, it would compile project successfully but not publish, neither Azure or Local Folder. > The core problem was that in reality the project didn't compile > successfully, that is if switched to "Release" mode in IDE, and doing > a "Rebuild Solution" errors that was not shown would appear. After > fixing the errors, the Publish would now Work. So seems as there is still a bug with "Publish...", that it suppresses Build Errors. – Daniel Halan Jun 15 '15 at 14:29

31 Answers31

106

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

Philippe
  • 548
  • 8
  • 24
Roberto Nunes
  • 1,326
  • 1
  • 9
  • 5
  • YEAH! This is the good answer. In my case I don't use the default "Release" or "Debug" profiles, but "DEV", "STAGE" and "LIVE". I've seen that e.g. for STAGE, on a colleague computer who downloaded my solution via TFS, the profile was wrongly set to "Release" (same for all the other profiles). So I simply had to correct it and point it to "STAGE" (or DEV / LIVE for the other ones). The Publish worked. Thank you. – firepol Oct 24 '13 at 12:05
  • Worked like a charm. This one should e the accepted answer. – Aycan Yaşıt Nov 21 '14 at 12:07
78

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

Dave Riedl
  • 900
  • 6
  • 6
  • 8
    This problem occurs for me on a fresh Visual Studio 2012 project. It published over FTP in the past, but now when I try to Publish it does exactly as above - it pretends to, says it was successful, and pushes nothing. It does build the output to the obj dir, but it never actually copies it to the server. The change Configuration trick does fix it though. – Chris Moschini Oct 06 '12 at 00:55
  • 12
    Hey! It's still broke in SP2! –  Apr 10 '13 at 20:26
  • 6
    I just had the same issue and realized it was because the publish settings defaults to "Any CPU", but my solution is set to "x86". Changing the Settings in the Publish to x86 fixed the issue. – Sam Apr 17 '13 at 17:57
  • None of solutions above work for me. Deleting profiles and recreating, changing configuration and changing back, restarting VS, rebuild all, etc. I created a new view in my app. It's there. I can see it. When I run locally it displays. When I publish, it's not there. I have update 4. – Robert Nov 05 '14 at 18:13
  • The only thing that works for me is deleting my view from the project and adding again. Seems to wake the IDE up to the notion that there is something new here. So wherever VS tracks project additions and subtractions may be involved. – Robert Nov 05 '14 at 19:22
  • Thanks @Sam. Changing "Any CPU" to "x86" worked. I then changed it back to "Any CPU" and it now publishes correctly. – Amanda Nov 25 '15 at 00:38
  • Thanks @iniki . Deleting profile and publishing with a new profile worked for me. – Abhimanyu Garg Dec 04 '15 at 06:44
40

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.

DdW
  • 890
  • 1
  • 18
  • 30
Eric Wild
  • 641
  • 5
  • 12
  • 5
    +1 That seemed to for me. It makes it slightly easier if you open the two files and compare them after creating a new profile. I also found that both files needed to be checked into source control if working in a team. – Deano Nov 22 '12 at 09:25
  • @Deano The problem with checking in any *.user file is that you no longer have the ability for individual (local) project customization. The point of the user file is to allow individual team members to have their own local settings. – Dave Riedl Nov 29 '12 at 18:20
  • Is there any another solution instead of adding ".pubxml.user" file into source control? – Jonas at Software Journey Mar 18 '13 at 09:34
  • We don't commit *.user files into source control, but incidentally, we don't use the publish profile inside Visual Studio, as our Continuous Integration server and build process manages all of that... – Brett Rigby May 02 '14 at 07:19
21

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

JGilmartin
  • 8,683
  • 14
  • 66
  • 85
  • This works for me, what i do was to delete the profiles in the local machine and recreate them. This does not affect the others development machines. – Jean Jimenez Aug 08 '13 at 22:09
  • I had this problem switching project from vs2013 to vs2012 and this completely fixed the problem – Sara Nikta Yousefi Mar 21 '15 at 08:32
  • This worked for me. I used these steps to rebuild my (file system) publish profile: http://stackoverflow.com/a/20616521/381082 – DeveloperDan Oct 01 '15 at 15:37
9

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

Stack User
  • 1,378
  • 5
  • 19
  • 40
8

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.

Community
  • 1
  • 1
Charles Wesley
  • 828
  • 12
  • 27
7

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.

Chris Hynes
  • 9,999
  • 2
  • 44
  • 54
7

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".

user2896889
  • 71
  • 1
  • 1
  • Yes this is what finally worked for me as well (tried all the other suggestions above). This is with vs2010 – Karen Oct 27 '15 at 21:14
5

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.

Bob Noordam
  • 61
  • 1
  • 2
  • Same workaround was the only fix for me as well. To clarify, steps: Build > Publish. Choose Settings tab at left. Change the Build Configuration to anything else. You'll see there's now an asterisk (*) next to the name of the Publish Profile - that's a sign the bug has been thwarted. Change the Build Configuration back to what you wanted. Proceed with the Publish as normal. Fixed. – Chris Moschini Oct 06 '12 at 00:57
4

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.

Matt Jordan
  • 91
  • 1
  • 3
  • 2
    We had this issue, seemed to be related to the pubxml.user file in the PublishProfiles folder under **My Project** - mine had a machine-generated list of files to publish, even though the [documentation](http://msdn.microsoft.com/en-us/library/ff398069) says this file is only for settings specific to me (and therefore isn't placed in source control). I was able to publish okay. My colleague took a fresh copy of our source code and was not able to publish - when his pubxml.user file was generated no files were listed. We have uninstalled the updated web publish and all is well again. – Nick Sep 05 '12 at 14:25
4

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".

KoalaBear
  • 2,755
  • 2
  • 25
  • 29
4

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.

dav_i
  • 27,509
  • 17
  • 104
  • 136
4

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

Yara
  • 4,441
  • 6
  • 42
  • 62
  • THAT WAS IT! The project had many files that were checked into source control, but were marked as `None` in the .csproj file, or were completely missing from the project (there but not "used")! This *fully* explains why running locally always worked, but publishing never did. :D – AndrewRalon Jun 08 '17 at 14:43
3

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.

mellodev
  • 1,597
  • 12
  • 20
2

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.

Todd Menier
  • 37,557
  • 17
  • 150
  • 173
1

This action was successful for me:

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

MichAdel
  • 737
  • 4
  • 3
1

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

Wilkoteq
  • 101
  • 1
  • 4
1

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.
Anja
  • 473
  • 4
  • 12
0

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.

Chris Moschini
  • 36,764
  • 19
  • 160
  • 190
0

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.

Candide
  • 30,469
  • 8
  • 53
  • 60
0

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.

Joebet
  • 1
  • 1
0

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

Dileep
  • 1
  • 1
0

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.)

Ryan Lundy
  • 204,559
  • 37
  • 180
  • 211
  • I'm experiencing a situation where a file or two seems to get overlooked and not published to the server, but, my .vbproj file already has both of the elements you suggest – bkwdesign Mar 04 '15 at 14:11
0

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.

saille
  • 9,014
  • 5
  • 45
  • 57
0

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.

Rahul Nikate
  • 6,192
  • 5
  • 42
  • 54
0

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.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
0

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.

Adam
  • 1,932
  • 2
  • 32
  • 57
0

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.

Jason Hitchings
  • 667
  • 8
  • 10
0

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

Andrew Cowenhoven
  • 2,778
  • 22
  • 27
-1

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!:)

Iceman
  • 6,035
  • 2
  • 23
  • 34
-2

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!
karthik
  • 17,453
  • 70
  • 78
  • 122
Ali A
  • 19