title: How do I copy files to another directory using MSBuild?
body: <p>I'm trying to copy several files in the $(TargetDir) to another folder (e.g. C:\BinCache), but for whatever reason I cannot get MSBuild to stop complaining.</p>
  
  <pre><code>  &lt;Target Name="AfterBuild"&gt;
      &lt;Copy SourceFiles="$(TargetDir)\*.*"
            DestinationFolder="C:\BinCache" /&gt;
    &lt;/Target&gt;
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>EDIT: The solution is to use a CreateItem task.  Presumably, Visual Studio 2008 removes this restriction. Thanks Scott!</p>
  
  <pre><code>&lt;Target Name="AfterBuild"&gt;
    &lt;CreateItem Include="$(TargetDir)\*.*"&gt;
      &lt;Output TaskParameter="Include" ItemName="SourceFiles" /&gt;
    &lt;/CreateItem&gt;
    &lt;Copy SourceFiles="@(SourceFiles)" DestinationFolder="C:\BinCache" /&gt;  
  &lt;/Target&gt;
  </code></pre>