MSBuild task for ILRepack which is an open-source alternative to ILMerge.
Install via NuGet
Install-Package ILRepack.MSBuild.Task
Supported build tools
- MSBuild
Usage - MSBuild
<!-- 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 -->
Task options
| Option | Description |
|---|---|
| KeyFile | Specifies a keyfile to sign the output assembly |
| LogFile | Specifies a logfile to output log information |
| Union | Merges types with identical names into one |
| DebugInfo | Enable/disable symbol file generation |
| AttributeFile | Take assembly attributes from the given assembly file |
| CopyAttributes | Copy assembly attributes |
| AllowMultiple | Allows multiple attributes (if type allows) |
| TargetKind | Target assembly kind (Exe|Dll|WinExe|SameAsPrimaryAssembly) |
| TargetPlatformVersion | Target platform (v1, v1.1, v2, v4 supported) |
| XmlDocumentation | Merge assembly xml documentation |
| LibraryPath | List of paths to use as "include directories" when attempting to merge assemblies |
| Internalize | Set all types but the ones from the first assembly 'internal' |
| InternalizeExclude | Assemblies that will not be internalized. |
| OutputFile | Output name for merged assembly |
| InputAssemblies | List of assemblies that will be merged |
| DelaySign | Set the keyfile, but don't sign the assembly |
| AllowDuplicateResources | Allows to duplicate resources in output assembly |
| ZeroPeKind | Allows assemblies with Zero PeKind (but obviously only IL will get merged) |
| Parallel | Use as many CPUs as possible to merge the assemblies |
| Verbose | Additional debug information during merge that will be outputted to LogFile |
| PrimaryAssemblyFile | Used in conjunction with Internalize to specify the main assembly filename |
| Wildcards | Allows (and resolves) file wildcards (e.g. `*`.dll) in input assemblies |
License
Checkout the License