VS 2015 community- Publish failed due to build errors.

I was experiencing the same problem and the accepted solution did not help, because the problem was with publishing, and not building (despite what the error says). I tried the accepted solution but it didn't help because there were no errors when building.

The solution for me was one of 2 options:

  1. Remove the option (in the publish profile) to delete existing files when publishing
  2. Ensure nothing is preventing file deletion - or more importantly folder deletion - on the target machine

I had a command prompt window open on the server, in a folder in the project directory which was preventing the folder from being deleted.


In Visual Studio go to Tools > Options and increase the MSBuild output verbosity. This will flood the Output window log with all the information you need:

enter image description here