Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Publish failed' but build succeeded?

When using Visual Studio 2008, when I "Publish Web Site", the application builds correctly, but then I get a "Publish failed" message:

enter image description here

What possible reasons are there for this, and how can I prevent it?

like image 434
Curtis Avatar asked Nov 14 '11 11:11

Curtis


4 Answers

I had the same issue. Nightmare to identify the problem, because the logs and outputs show no errors or failures. I simply get "Build: 39 succeeded" and "Publish: 1 failed".

I resolved the problem by systematically removing all NuGet packages one at a time (and removing code that references it) until I identified the offending one.

This takes a LONG time!

However, the answer for me was Microsoft.Net.Compilers.

No idea how I ended up with that in my project, but as soon as I removed that package, everything publishes fine again.

Edit - For what it's worth, this problem occurs on VS 2008, 2012 and 2015 but does not occur on 2017.

like image 51
SimonGoldstone Avatar answered Nov 16 '22 10:11

SimonGoldstone


You can try this:

  1. Perform precompilation against the web application.

  2. Clear the target directory(virtual directory in IIS or physical file folder) and deploy all the files (of the web application) into the target directory.

In the output window you can check at which stage does the publish website operation fail. For example, at the first stage, if there are some error which will only occur at precompilation, that will cause the stage 1 fail. Or some times if the target directory has something configured incorrectly. Such as the IIS virtual dir is not set to the correct ASP.NET version or some old files are locked and prevent them from being cleared. Mostly, publish failed will be caused by IIS side configuration issue such as authentication setting....

Source link

You can open the output window by pressing Ctrl+W, O.

like image 36
NaveenBhat Avatar answered Nov 16 '22 09:11

NaveenBhat


Sometimes it's because you need to be running VS as Administrator to be able to write to the target directory.

Check the Output messages, they should help you solve the problem

like image 11
Nick Avatar answered Nov 16 '22 09:11

Nick


I had to copy project to C:\a\ and than publish. I suspect problems with long path. Strange, but worked for me.

like image 5
vt100 Avatar answered Nov 16 '22 10:11

vt100