1

In Visual Studio 2010, I have just one project that cannot be published using the "Publish Now" button.

enter image description here

enter image description here

If I publish using the menu option instead, it works fine. I can then increment the version number, click "Publish Now" (or use "Publish Wizard..."), and get this error:

Cannot publish because a project failed to build.

However, no other error message is given. I managed to get screenshots of the output screen before it clears and flips to the Error List tab, but there is no mention there of any error. Clean & Rebuild doesn't fix the problem.

What do these two options do differently? Why is the build failing one way but not the other?

Ivy
  • 887
  • 1
  • 7
  • 25

3 Answers3

3

Since "rebuild solution" and "clean Solution" are not solving these issues, it might be either logs or assemblies in Bin.

This error seems to be caused by various issues :

Solution 1. set the build log verbosity to Diagnostic from the menu Tools->Options->Project and Solutions->Build and Run in Visual Studio 2010.

After that, if you build and publish your project, you can see the detailed build log from the Output window. From there, we should get futher information about why it failed to build.

Solution 2. Do you have Google Desktop by chance? If you do, close the sidebar and try once.

Solution 3. Click here for an another solution

Solution 4. Do you work with people from other timezones ? Files modified in future time may also cause this issue. check this utility

Solution 5.
I suggest you to try running the Visual Studio in safemode that will force the visual studio loading only the default environment and services, and shipped versions of third party packages. If the problem disappears you may stuck with some version of IDE tools with bugs. update them then.

If nothing seems to work, try this. *Solution 6* 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 tag.

<Target Name="BeforePublish">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(IntermediateOutputPath)" />
</Target> 
Sakthivel
  • 1,890
  • 2
  • 21
  • 47
  • The log disappears immediately, but I managed to crash VS before it cleared. The log is too large to copy, but the last thing in it is `Done executing task "ResolveManifestFiles" -- FAILED. (TaskId:222)` – Ivy Jul 24 '13 at 17:52
  • I do not have Google Desktop. – Ivy Jul 24 '13 at 20:08
  • http://stackoverflow.com/questions/7869129/clickonce-cannot-publish-because-a-project-failed-to-build – Sakthivel Jul 25 '13 at 06:10
  • Solution 5 worked for me. In my case, Red Gate's SQL Prompt was causing the issue. Had this issue for months. Uninstalled plug-in and now it works fine. – Rob Jul 24 '14 at 15:28
1

Clean and Rebuild worked for me. It seems like Google desktop and some browser extenstions causing this bug often. looking for a security update is good way to go with this.

Shakimaru
  • 11
  • 2
  • It only happens with this one project. Other projects publish this way without issue. (also I do not use Google desktop) – Ivy Nov 15 '13 at 22:56
1

I eventually created a new branch, and that branch did not have this problem. I never discovered what the actual cause was.

Ivy
  • 887
  • 1
  • 7
  • 25