title: How do I exclude a specific file from my msbuild AfterBuild target
body: <p>I have this msbuild target in my csproj file:</p>
  
  <pre><code>&lt;Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' "&gt;
      &lt;CreateItem Condition="'%(Extension)'=='.dll'" Include="@(ReferenceCopyLocalPaths)"&gt;
          &lt;Output TaskParameter="Include" ItemName="IlmergeAssemblies" /&gt;
      &lt;/CreateItem&gt;
      &lt;Exec Command="&amp;quot;$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe&amp;quot; /targetplatform:&amp;quot;v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319&amp;quot; /ndebug /out:@(MainAssembly) &amp;quot;@(IntermediateAssembly)&amp;quot; @(IlmergeAssemblies-&gt;'&amp;quot;%(FullPath)&amp;quot;', ' ')" /&gt;
      &lt;Delete Files="@(ReferenceCopyLocalPaths-&gt;'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>This works like a charm. But I want it to exclude a specific file and tried to tweak it:</p>
  
  <pre><code>&lt;Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' "&gt;
      &lt;CreateItem Condition="'%(Extension)'=='.dll' AND '%(Filename)' != 'Foo.dll'" Include="@(ReferenceCopyLocalPaths)"&gt;
          &lt;Output TaskParameter="Include" ItemName="IlmergeAssemblies" /&gt;
      &lt;/CreateItem&gt;
      &lt;Exec Command="&amp;quot;$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe&amp;quot; /targetplatform:&amp;quot;v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319&amp;quot; /ndebug /out:@(MainAssembly) &amp;quot;@(IntermediateAssembly)&amp;quot; @(IlmergeAssemblies-&gt;'&amp;quot;%(FullPath)&amp;quot;', ' ')" /&gt;
      &lt;Delete Files="@(ReferenceCopyLocalPaths-&gt;'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>However, this doesn't work. Does anyone know what I'm doing wrong?</p>