我想在我的MSBuild管道中集成.Net核心项目的ILRepack,以便将所有需要的dll合并到单个exe/dll中。
有用的NuGet-Package ILRepack.MSBuild.Task似乎非常适合这一点,但是GitHub自述文件中的示例不太适用于.Net核心项目,我不知道如何更改它才能与.Net核心项目兼容:
<!-- ILRepack -->
<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge1.dll" />
<InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge2.dll" />
<InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge3.dll" />
</ItemGroup>
<ItemGroup>
<!-- Must be a fully qualified name -->
<DoNotInternalizeAssemblies Include="ExampleAssemblyToMerge3" />
</ItemGroup>
<ILRepack
Parallel="true"
Internalize="true"
InternalizeExclude="@(DoNotInternalizeAssemblies)"
InputAssemblies="@(InputAssemblies)"
TargetKind="Dll"
OutputFile="$(OutputPath)\$(AssemblyName).dll"
/>
</Target>
<!-- /ILRepack -->澄清:
我只想使用.Net--Format引入的.csproj-Format,但实际上使用的是net461作为TargetPlatform。
发布于 2018-01-09 22:01:39
将此用于.Net核心项目:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ILRepack" Version="2.0.15" />
<PackageReference Include="ILRepack.MSBuild.Task" Version="1.0.9" />
</ItemGroup>
<!-- ILRepack -->
<Target Name="ILRepack" AfterTargets="Build">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge1.dll" />
<InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge2.dll" />
<InputAssemblies Include="$(OutputPath)\ExampleAssemblyToMerge3.dll" />
</ItemGroup>
<ItemGroup>
<!-- Must be a fully qualified name -->
<DoNotInternalizeAssemblies Include="ExampleAssemblyToMerge3" />
</ItemGroup>
<ILRepack
Parallel="true"
Internalize="true"
InternalizeExclude="@(DoNotInternalizeAssemblies)"
InputAssemblies="@(InputAssemblies)"
TargetKind="Dll"
OutputFile="$(OutputPath)\$(AssemblyName).dll" />
</Target>
<!-- /ILRepack -->
</Project>备注
您也可以使用一个<InputAssemblies Include="$(OutputPath)\*.dll" />来合并输出文件夹中的所有dll文件
https://stackoverflow.com/questions/48169876
复制相似问题