MSBuild包含/排除无法正常工作

时间:2018-12-03 07:02:29

标签: c# .net msbuild

由于某些原因,我的文件未被排除:

  <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Zip'">
    <ItemGroup>
      <ZipFiles Include="$(OutDir)\*.*" Exclude="*.nupkg;*.vshost.*;*.xml;*.pdb;*.snk*;Squirrel.dll;NuGet.Squirrel.dll;Splat.dll;DeltaCompressionDotNet.*;Mono.*" />
    </ItemGroup>
    <Message Importance="High" Text="Result files: @(ZipFiles)" />
    <Zip Files="@(ZipFiles)" WorkingDirectory="$(OutDir)" ZipFileName="../Releases/HotsApi.zip" ZipLevel="9" />
  </Target>

输出:

Result files: bin\Zip\DeltaCompressionDotNet.dll;bin\Zip\DeltaCompressionDotNet.MsDelta.dll;bin\Zip\DeltaCompressionDotNet.PatchApi.dll;bin\Zip\Heroes.ReplayParser.netstandard.dll;bin\Zip\Heroes.ReplayParser.netstandard.pdb;bin\Zip\Hotsapi.Uploader.Common.dll;bin\Zip\Hotsapi.Uploader.Common.pdb;bin\Zip\Hotsapi.Uploader.exe;bin\Zip\Hotsapi.Uploader.exe.config;bin\Zip\Hotsapi.Uploader.pdb;bin\Zip\Mono.Cecil.dll;bin\Zip\Mono.Cecil.Mdb.dll;bin\Zip\Mono.Cecil.Pdb.dll;bin\Zip\Mono.Cecil.Rocks.dll;bin\Zip\MpqTool.netstandard.dll;bin\Zip\MpqTool.netstandard.pdb;bin\Zip\Newtonsoft.Json.dll;bin\Zip\Nito.AsyncEx.Coordination.dll;bin\Zip\Nito.AsyncEx.Tasks.dll;bin\Zip\Nito.Collections.Deque.dll;bin\Zip\Nito.Disposables.dll;bin\Zip\NLog.config;bin\Zip\NLog.dll;bin\Zip\NuGet.Squirrel.dll;bin\Zip\NuGet.Squirrel.pdb;bin\Zip\SharpCompress.dll;bin\Zip\Splat.dll;bin\Zip\Splat.pdb;bin\Zip\Squirrel.dll;bin\Zip\Squirrel.pdb;bin\Zip\System.Collections.Immutable.dll

MSBuild似乎忽略了我的Exclude子句。我在做什么错了?

1 个答案:

答案 0 :(得分:2)

排除模式需要与每个目录的搜索模式相匹配,所以您想要的是

Exclude="**\*.nupkg;**\*.pdb;…"