title: MSBuild: asterisks and strange ItemGroup Exclude behaviour
body: <p>I have a script that attempts to construct an <code>ItemGroup</code> out of all files in a certain directory while excluding files with certain names (regardless of extension).</p>
  
  <p>The list of files to be excluded initially contains file extensions, and I am using Community Tasks' <code>RegexReplace</code> to replace the extensions with an asterisk. I then use this list in the item's <code>Exclude</code> attribute. For some reason the files do not get excluded properly, even though the list appears to be correct.</p>
  
  <p>To try and find the cause I created a test script (below) which has two tasks: first one initialises two properties with the list of file patterns in <strong>two different ways</strong>. The second task prints both properties and the files resulting from using both these properties in the <code>Exclude</code> attribute.</p>
  
  <p>The properties' values appear to be identical, however the resulting groups are different. How is this possible?</p>
  
  <pre><code>&lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
           DefaultTargets="Init;Test" ToolsVersion="3.5"&gt;
    &lt;Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/&gt;
  
    &lt;Target Name="Init"&gt;
      &lt;ItemGroup&gt;
        &lt;OriginalFilenames Include="TestDir\SampleProj.exe"/&gt;
        &lt;OriginalFilenames Include="TestDir\SampleLib1.dll"/&gt;
      &lt;/ItemGroup&gt;
      &lt;RegexReplace Input="@(OriginalFilenames)" Expression="\.\w+$" Replacement=".*"&gt;
        &lt;Output TaskParameter="Output" ItemName="PatternedFilenames"/&gt;
      &lt;/RegexReplace&gt;
      &lt;PropertyGroup&gt;
        &lt;ExcludeFilesA&gt;TestDir\SampleProj.*;TestDir\SampleLib1.*&lt;/ExcludeFilesA&gt;
        &lt;ExcludeFilesB&gt;@(PatternedFilenames)&lt;/ExcludeFilesB&gt;
      &lt;/PropertyGroup&gt;
    &lt;/Target&gt;
  
    &lt;Target Name="Test"&gt;
      &lt;Message Text='ExcludeFilesA: $(ExcludeFilesA)' /&gt;
      &lt;Message Text='ExcludeFilesB: $(ExcludeFilesB)' /&gt;
      &lt;ItemGroup&gt;
        &lt;AllFiles Include="TestDir\**"/&gt;
        &lt;RemainingFilesA Include="TestDir\**" Exclude="$(ExcludeFilesA)"/&gt;
        &lt;RemainingFilesB Include="TestDir\**" Exclude="$(ExcludeFilesB)"/&gt;
      &lt;/ItemGroup&gt;
      &lt;Message Text="&amp;#xA;**AllFiles**&amp;#xA;@(AllFiles, '&amp;#xA;')" /&gt;
      &lt;Message Text="&amp;#xA;**PatternedFilenames**&amp;#xA;@(PatternedFilenames, '&amp;#xA;')" /&gt;
      &lt;Message Text="&amp;#xA;**RemainingFilesA**&amp;#xA;@(RemainingFilesA, '&amp;#xA;')" /&gt;
      &lt;Message Text="&amp;#xA;**RemainingFilesB**&amp;#xA;@(RemainingFilesB, '&amp;#xA;')" /&gt;
    &lt;/Target&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>Output (reformatted somewhat for clarity):</p>
  
  <pre><code>ExcludeFilesA: TestDir\SampleProj.*;TestDir\SampleLib1.*
  ExcludeFilesB: TestDir\SampleProj.*;TestDir\SampleLib1.*
  
  AllFiles:
    TestDir\SampleLib1.dll
    TestDir\SampleLib1.pdb
    TestDir\SampleLib2.dll
    TestDir\SampleLib2.pdb
    TestDir\SampleProj.exe
    TestDir\SampleProj.pdb
  
  PatternedFilenames:
    TestDir\SampleProj.*
    TestDir\SampleLib1.*
  
  RemainingFilesA:
    TestDir\SampleLib2.dll
    TestDir\SampleLib2.pdb
  
  RemainingFilesB:
    TestDir\SampleLib1.dll
    TestDir\SampleLib1.pdb
    TestDir\SampleLib2.dll
    TestDir\SampleLib2.pdb
    TestDir\SampleProj.exe
    TestDir\SampleProj.pdb
  </code></pre>
  
  <p>Observe that both <code>ExcludeFilesA</code> and <code>ExcludeFilesB</code> look identical, but the resulting groups <code>RemainingFilesA</code> and <code>RemainingFilesB</code> differ.</p>
  
  <p>Ultimately I want to obtain the list <code>RemainingFilesA</code> using the pattern generated the same way <code>ExcludeFilesB</code> is generated. Can you suggest a way, or do I have to completely rethink my approach?</p>