title: Trying to exclude certain extensions doing a recursive copy (MSBuild)
body: <p>I'm trying to use MSBuild to read in a list of files from a text file, and then perform a recursive copy, copying the contents of those directories files to some staging area, <em>while excluding certain extensions</em> (e.g. .tmp files)</p>
  
  <p>I've managed to do most of the above quite easily using CreateItem and the MSBuild copy task, whatever I do the CreateItem task just ignores my Exclude parameter:</p>
  
  <pre><code>&lt;PropertyGroup&gt;
    &lt;RootFolder&gt;c:\temp&lt;/RootFolder&gt;
    &lt;ExcludeFilter&gt;*.tmp&lt;/ExcludeFilter&gt;
    &lt;StagingDirectory&gt;staging&lt;/StagingDirectory&gt;
  &lt;/PropertyGroup&gt;
  &lt;ItemGroup&gt;
    &lt;InputFile Include="MyFile.txt" /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;Target Name="Build"&gt;
    &lt;ReadLinesFromFile File="@(InputFile)"&gt;
      &lt;Output ItemName="AllFolders" TaskParameter="Lines" /&gt;
    &lt;/ReadLinesFromFile&gt;
  
    &lt;CreateItem Include="$(RootFolder)\%(AllFolders.RelativeDir)**"
                Exclude="$(ExcludeFilter)"&gt;
      &lt;Output ItemName="AllFiles" TaskParameter="Include" /&gt;
    &lt;/CreateItem&gt;
  
    &lt;Copy SourceFiles="@(AllFiles)"
          DestinationFolder="$(StagingDirectory)\%(RecursiveDir)" 
  </code></pre>
  
  <p>Example contents of 'MyFile.txt':</p>
  
  <pre><code>somedirectory\
  someotherdirectory\
  </code></pre>
  
  <p>(I.e. the paths are relative to <code>$(RootFolder)</code> - mention this because I read somewhere that it might be relevant)</p>
  
  <p>I've tried loads of different combinations of Exclude filters, but I never seem to be able to get it to correctly exclude my .tmp files - is there any way of doing this with MSBuild without resorting to xcopy?</p>