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:
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>
You can achieve this with incremental building that is provided out of the box with MSBuild.
Sayed Ibrahim Hashimi
My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With