none
Build with copying dlls - how not copy if unchanged

    Question

  • Hi all,

    I am wondering if anyone can help me with an issue that I have with the current build process on my project.  The project is using VS2005 mostly in C# but also in C++.  For each project in the HUGE solution that we have, we are copying the dll(s) and exe(s) [units and final] to the main bin directory in the project structure.  This works great, but the problem is that, whenever I make a change and go to test it, the compile takes forever because VS2005 is still copying the dlls for every project, even though only one file got changed that affected nothing else except its own project.

    The way we are doing this is that, in the Properties for any given project, we have the following copy commands:

    For C#: Post-build event command line:
    copy $(TargetFileName) ..\..\..\..\$(ConfigurationName)\bin\$(TargetFileName)

    For C++: Configuration Properties/Build Events/Post-Build Event:
    copy $(OutDir)\$(ProjectName).dll ..\..\$(ConfigurationName)\bin\$(ProjectName).dll

    This does not seem to allow for checking whether these dlls and exes have actually been changed or not.  I am not sure if there is an undocumented switch for copy which will allow for this check, but I don't think so.  Is this the only way to have these copies made? or is there a better way: one that is actually smart, and checks whether the copy even needs to happen.

    I am so over this whole build routine.  Please someone, help me here...
    Bruce
    Friday, September 28, 2007 4:12 PM

Answers

  • For the C# projects, you might want to actually take advantage of msbuild. To do so you'll want to remove the post-build from the properties, edit the .csproj files according to the following (for instructions on how to go about editing see e.g. http://mostlytech.blogspot.com/2007/05/editing-visual-studio-2005-project-file.html)

     

    At the end of the file you'll likely see a commented out section containing among other things the following:

     

    Code Block

    <Target Name="AfterBuild">

    </Target>

     

    This you'll want to uncomment and change it like so:

     

    Code Block

    <Target Name="AfterBuild">

    <Copy SkipUnchangedFiles="true" SourceFiles="$(TargetFileName)"

    DestinationFiles="..\..\..\..\$(Configuration)\bin\$(TargetFileName)" />

    </Target>

     

     

     

    Unfortunately C++ projects are not msbuild compatible so you cannot do the same there...
    Friday, September 28, 2007 6:53 PM