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.