views:

58

answers:

1

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.

+3  A: 

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.

David Schmitt
Is there a way to set those XML elements directly into Visual Studio?Or have I to edit the .csproj manually?Thank you again.
Maurizio Reginelli
you have to add it to the .csproj manually, but the studio will leave it in place.
David Schmitt