首先,我的建议是使用ILRepack,因为不再积极维护 ILMerge。ILRepack 基于 ILMerge 并且是开源的。将 NuGet 包添加ILRepack.Lib.MSBuild.Task
到您的项目。
然后将此文件添加到您的项目中并命名ILRepack.targets
:
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="ILRepacker" AfterTargets="Build">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)$(TargetName)$(TargetExt)" />
<InputAssemblies Include="$(OutputPath)YourFramework.dll" />
</ItemGroup>
<ILRepack
Parallel="true"
Internalize="false"
InternalizeExclude="@(DoNotInternalizeAssemblies)"
InputAssemblies="@(InputAssemblies)"
LibraryPath="$(OutputPath)"
Wildcards="false"
TargetKind="SameAsPrimaryAssembly"
DebugInfo="false"
KeyFile="YourCompany.snk"
OutputFile="$(OutputPath)Merged\$(AssemblyName).dll"
LogFile="$(OutputPath)Merged\ILRepack.log"
/>
</Target>
</Project>
请注意,根据此配置,您的合并 dll 将在名为“Merged”的单独文件夹中创建。这是您在 Dynamics 365 上注册的库。您的单元测试应该只使用插件项目的常规生成输出。