In MSBuild I can use the Copy
task to copy files from one location to another.
I can also use the SkipUnchangedFiles
property to specify that files should not be copied if they have not changed.
Is there a standard pattern for predicating a follow-up action on the condition that one or more files were copied?
For example:
- Copy any updated deployment scripts
- Execute the batch file which runs all the deployment scripts, in the correct order, if and only if one or more of the scripts have changed
One further complication is that I am using the CreateItem
task to dynamically generate the list of input files:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="CopyAndRun">
<Target Name="CopyAndRun">
<CreateItem Include="In\**\*Test*.txt">
<Output TaskParameter="Include" ItemName="SourceFiles"/>
</CreateItem>
<Copy SourceFiles="%(SourceFiles.Identity)" DestinationFolder="Out\%(RecursiveDir)" SkipUnchangedFiles="true" />
<!-- Only want to execute this if updated files were copied -->
<Message Text="Running..." />
</Target>
</Project>