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