我的csproj文件中有这个msbuild目标:
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
<CreateItem Condition="'%(Extension)'=='.dll'" Include="@(ReferenceCopyLocalPaths)">
<Output TaskParameter="Include" ItemName="IlmergeAssemblies" />
</CreateItem>
<Exec Command=""$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe" /targetplatform:"v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319" /ndebug /out:@(MainAssembly) "@(IntermediateAssembly)" @(IlmergeAssemblies->'"%(FullPath)"', ' ')" />
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</Target>
这就像一个魅力。但我希望它排除一个特定的文件,并试图调整它:
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
<CreateItem Condition="'%(Extension)'=='.dll' AND '%(Filename)' != 'Foo.dll'" Include="@(ReferenceCopyLocalPaths)">
<Output TaskParameter="Include" ItemName="IlmergeAssemblies" />
</CreateItem>
<Exec Command=""$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe" /targetplatform:"v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319" /ndebug /out:@(MainAssembly) "@(IntermediateAssembly)" @(IlmergeAssemblies->'"%(FullPath)"', ' ')" />
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</Target>
然而,这不起作用。有谁知道我做错了什么?
答案 0 :(得分:4)
%(文件名)仅包含文件名。
所以你可以测试%(Filename)'!='Foo':
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
<CreateItem Condition="'%(Extension)'=='.dll' AND '%(Filename)' != 'Foo'" Include="@(ReferenceCopyLocalPaths)">
<Output TaskParameter="Include" ItemName="IlmergeAssemblies" />
</CreateItem>
<Exec Command=""$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe" /targetplatform:"v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319" /ndebug /out:@(MainAssembly) "@(IntermediateAssembly)" @(IlmergeAssemblies->'"%(FullPath)"', ' ')" />
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />