开发者

Visual Studio 2010 Ultimate Publish Problem

开发者 https://www.devze.com 2023-03-01 21:18 出处:网络
I have a开发者_StackOverflow WPF C# 4.0 Application. I was publishing projects fine before but all of a sudden one particular project starts to not publish. I get the following errors after a successf

I have a开发者_StackOverflow WPF C# 4.0 Application. I was publishing projects fine before but all of a sudden one particular project starts to not publish. I get the following errors after a successful build.

Error 2 Could not find file 'obj\x86\Release\CSCDemo.exe'. CSCDemo.0

Next error is 'failed to Publish'

I know that CSCDemo.exe is in the Release folder because I checked.

Would Microsoft Visual Studio 2010 Service Pack 1 fix this?


The packager is looking at the obj\x86 folder, not the normal bin\release folder for your exe. I am thinking the issue has to do with either the packager looking in the wrong place or you have changed the project properties for your CSCDemo project. Have you changed it from being an x86 application to x64?

Another thing to try would be a complete rebuild.


I have just suffered from this problem. It seems my Avast Anti-Virus was deleting the file as soon as it was created. I just added my project folder to it's global exclude list and everything worked fine again.


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 followign section just before the final </project> tag.

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


change the platform from x86 to Any CPU will help

Build>configuration manager change the platform against CSCDemo to Any CPU

0

精彩评论

暂无评论...
验证码 换一张
取 消