'$(OutD-6ren">
gpt4 book ai didi

configuration - 如何从我的 msbuild AfterBuild 目标中排除特定文件

转载 作者:行者123 更新时间:2023-12-04 18:18:54 26 4
gpt4 key购买 nike

我的 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>

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

最佳答案

%(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)')" />

关于configuration - 如何从我的 msbuild AfterBuild 目标中排除特定文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11120819/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com