'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:
What possible reasons are there for this, and how can I prevent it?
Solution 1:
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.
Solution 2:
You can try this:
Perform precompilation against the web application.
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.
Solution 3:
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
Solution 4:
I had to copy project to C:\a\
and than publish. I suspect problems with long path. Strange, but worked for me.