1

我正在做概念验证以了解 ILRepack (ILRepack.MSBuild.Task) 的工作原理。

使用此配置,我可以创建一个合并的 dll,其中 ClassLibrary1、AutoMapper 和 Newtonsoft.Json 正确内部化:

 <Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'">
<ItemGroup>
  <InputAssemblies Include="$(OutputPath)\ClassLibrary2.dll" />
  <InputAssemblies Include="$(OutputPath)\ClassLibrary1.dll" />
  <InputAssemblies Include="$(OutputPath)\AutoMapper.dll" />
  <InputAssemblies Include="$(OutputPath)\Newtonsoft.Json.dll" />
</ItemGroup>
<ItemGroup>
  <!-- Must be a fully qualified name -->
  <DoNotInternalizeAssemblies Include="ClassLibrary2" />
</ItemGroup>
<ILRepack Parallel="true" Internalize="true" InternalizeExclude="@(DoNotInternalizeAssemblies)" InputAssemblies="@(InputAssemblies)" TargetKind="Dll" OutputFile="$(OutputPath)\$(AssemblyName).dll" />

但是,当我尝试使用通配符时, internalize 不起作用:

 <Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'">
<ItemGroup>
  <InputAssemblies Include="$(OutputPath)\*.dll" />
</ItemGroup>
<ItemGroup>
  <!-- Must be a fully qualified name -->
  <DoNotInternalizeAssemblies Include="ClassLibrary2" />
</ItemGroup>
<ILRepack Parallel="true" Internalize="true" InternalizeExclude="@(DoNotInternalizeAssemblies)" InputAssemblies="@(InputAssemblies)" TargetKind="Dll" OutputFile="$(OutputPath)\$(AssemblyName).dll" />

知道为什么会这样吗?

编辑:看起来通配符重新排序程序集。Automapper 没有内化(因为成为主程序集),但所有其他都是(除了 ClassLibrary2,我想 DoNotInternalizeAssemblies 可以完成它的工作)

4

0 回答 0