我正在做一个概念的证明来理解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" />
然而,当我试图使用通配符时,内部化不起作用:
<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完成了它的工作)
发布于 2022-05-05 07:41:10
它可能是随着时间的推移而增加的。您可以指定WilcardInputAssemblies="true".
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ILRepack.MSBuild.Task" Version="2.0.1" />
</ItemGroup>
<Target Name="ILRepack" AfterTargets="Build">
<PropertyGroup>
<WorkingDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\$(TargetFramework)</WorkingDirectory>
</PropertyGroup>
<ILRepack
OutputType="$(OutputType)"
MainAssembly="$(AssemblyName).dll"
OutputAssembly="$(AssemblyName).dll"
InputAssemblies="$(WorkingDirectory)\*.dll"
WilcardInputAssemblies="true"
WorkingDirectory="$(WorkingDirectory)" />
</Target>https://stackoverflow.com/questions/40766405
复制相似问题