'Publish failed' but build succeeded?

80,607

Solution 1

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.

Solution 2

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

Solution 5

The conclusion is: Try another VS edition and see if that does it.

Here is what did it for me.

I have VS 2013 Pro and Visual Studio 2015 Community. I sort of use one or another to work on my MVC project and all was fine. Then all of the sudden VS 2013 could not publish though it would build just fine. There was no erros other than some silly ...code is not returned from all paths...

So when I open it in VS 2017 - it published the same project just fine. I am suspecting a compiling issue - be cause that was the stage it would fail at.

Hope that helps you save a bit of time.

Share:
80,607
Curtis
Author by

Curtis

https://curtiscode.dev

Updated on July 09, 2022

Comments

  • Curtis
    Curtis almost 2 years

    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?