ClickOnce - Cannot publish because a project failed to build ClickOnce - Cannot publish because a project failed to build wpf wpf

ClickOnce - Cannot publish because a project failed to build


This is a problem with Visual Studio that can occur when you have add-ins installed. Instead of using the Publish button in the Publish tab, use Build/Publish from the menu on the top of Visual Studio.

If you use the Publish button, it runs through the add-ins before doing the build (or something like that). If you use Build from the menu instead, it goes straight to msbuild and ignores any add-ins you have installed.

If you have DevExpress installed and are still having problems, check out this article:http://www.devexpress.com/Support/Center/p/Q260132.aspx


With the date back to normal, close VS and try deleting your *.suo files next to the *.sln files and then reopen the solution


I'm not sure exactly how your development machine can get fouled up this way, but this started happening for several developers in our group too.

After researching it, it appears that the built in build/publish script that Visual Studio (2010 in our case) uses has a flaw in the order that it does things. Most importantly it runs a cleanup on the OBJ directory deleting the target EXE file before the publish step can grab it.

The solution
This is somewhat of a hacky workaround, but it solved the problem for me.

The fix is to copy the file back to the /obj/ folder from the /bin/ folder right before the publish step. Unfortunately there is no way that I know to specify a BeforePublish event through the IDE, so you will have to edit the .vbproj file in a text editor.

Add the following section just before the final </project> tag.

<Target Name="BeforePublish"><Copy SourceFiles="$(TargetPath)" DestinationFolder="$(IntermediateOutputPath)" /></Target>