Batch files in Visual Studio 2008

吃可爱长大的小学妹 提交于 2019-12-12 17:24:41

问题


I need help with a very frustrating problem with Visual Studio 2008.
I have a project in C# which calls, during the pre-compilation phase, a batch file which copies some dlls into a sub-directory of the project itself. It often happens that Visual Studio reports an error caused by the execution of the batch file: it says that the execution had terminated with code 1. After that, the only solution to compile again the project is restarting Visual Studio. Once restarted, the compilation doesn't report any problem.
Is there anyone who report the same problem?
Do you know a way to resolve it?
Thank you very much.


回答1:


Use a <copy/> task instead. This will give you better error handling.

Example to copy all DLLs from C:\SourceDir to LocalDir:

<ItemGroup>
  <SourceFiles Include="C:\SourceDir\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(SourceFiles )" DestinationFolder="LocalDir\" />

See also the MSDN CopyTask Reference.

The root cause is probably the studio itself having still the assemblies open via the "Visual Studio hosting process". You can disable this in the project's properties under "Debug", "Enable the Visual Studio hosting process". See the Debugging and the Hosting Process article for details.



来源:https://stackoverflow.com/questions/2251983/batch-files-in-visual-studio-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!