6

I am using a Custom Build Step to copy the built DLL (i.e. $(TargetPath)) of a C++ project to a different location on disk.

I've set the Output of the Custom Build Step to the destination DLL path, and Additional Dependencies to $(TargetPath) - the file I'm copying, in the hope that VS will then only run the step if the source DLL is newer than the target DLL.

However, each time I build the project, VS runs the custom build step - so it appears to be unable to tell that there's no need to perform the copy, (the source DLL $(TargetPath) hasn't changed). I must have the step configured incorrectly.

What settings will give me the behaviour that I want (i.e. - VS regards the project as up-to-date if it built and the custom build step was successful)?

In the VS Output Window I see this line which seems to imply that visual studio is taking the vcxproj as the file that triggers the build step. I want it to use $(TargetPath):

Input file "MyProject.vcxproj" is newer than output file "c:\custom\build\step\copies\the\dll\here.dll".

(PS: I should add, I was initially using a Post Build Step, but if this fails, VS regards the project as successfully built, and doesnt run it again when you Build a second time)

mackenir
  • 10,801
  • 16
  • 68
  • 100

2 Answers2

0

I think what you want is Incremental Building.

Here is a quick howto on it: http://msdn.microsoft.com/en-us/library/ms171483.aspx

The basics are you need to supply an input to the target to so MSBuild can map the inputs to outputs and skip the target if the output is newer/same age as the input.

Andy Eskridge
  • 260
  • 2
  • 14
  • 1
    I don't think so. I'm in a Visual Studio project, so the build target is already defined as the DLL that gets built. – mackenir Oct 21 '13 at 10:42
0

Make sure the timestamp of the output file you specified is updated after the copy command (in Unix you would use the touch command).

You may use this at the Command Line:

cd c:\custom\build\step\copies\the\dll <br>
copy /b /y YOUR_SOURCE_DIRECTORY/here.dll .<br>
copy /b /y here.dll+,,
Andy
  • 49,085
  • 60
  • 166
  • 233
Schlacki
  • 173
  • 1
  • 10