ClickOnce - Cannot publish because a project failed to build

后端 未结 11 1425
你的背包
你的背包 2020-12-14 07:10

When I try to publish my (WPF, C#) application, I get these errors:
Cannot publish because a project failed to build.
Could not find file \'obj\\x86\\Debug

相关标签:
11条回答
  • 2020-12-14 08:04

    Closing and Opening Visual Studio worked for me.

    0 讨论(0)
  • 2020-12-14 08:07

    I have sometimes had problems with an ASP.NET project publishing, because the publish wizard couldn't delete files in the directory it was trying to publish the files to.

    Try clearing out those file manually before publishing. Also check the output window; it will sometimes give you some hints as to why the publish failed.

    0 讨论(0)
  • 2020-12-14 08:08

    I've had this error when I'd been swapping git branches. A Rebuild All fixed this for me.

    0 讨论(0)
  • 2020-12-14 08:10

    In my case, the problem arise when I added the following section in .csproj File:

    <Target Name="AfterBuild">
    </Target>
    
    0 讨论(0)
  • 2020-12-14 08:12

    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> 
    
    0 讨论(0)
提交回复
热议问题