2

我的 csproj 文件中有这个 msbuild 目标:

<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
    <CreateItem Condition="'%(Extension)'=='.dll'" Include="@(ReferenceCopyLocalPaths)">
        <Output TaskParameter="Include" ItemName="IlmergeAssemblies" />
    </CreateItem>
    <Exec Command="&quot;$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe&quot; /targetplatform:&quot;v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319&quot; /ndebug /out:@(MainAssembly) &quot;@(IntermediateAssembly)&quot; @(IlmergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" />
    <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="&quot;$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe&quot; /targetplatform:&quot;v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319&quot; /ndebug /out:@(MainAssembly) &quot;@(IntermediateAssembly)&quot; @(IlmergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" />
    <Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</Target>

但是,这不起作用。有谁知道我做错了什么?

4

1 回答 1

4

%(Filename) 仅包含文件名。

所以你可以测试%(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="&quot;$(ProjectDir)..\..\..\tools\IlMerge\Ilmerge.exe&quot; /targetplatform:&quot;v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319&quot; /ndebug /out:@(MainAssembly) &quot;@(IntermediateAssembly)&quot; @(IlmergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" />
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />

于 2012-06-20T13:47:39.900 回答