Skip to content

Repository files navigation

ILRepack.Lib.MSBuild.Task

MSBuild task for ILRepack which is an open-source alternative to ILMerge.

Install via NuGet NuGetNuGet

 Install-Package ILRepack.Lib.MSBuild.Task

Supported build tools

  • MSBuild

Usage

You need to install the NuGet package to merge all your project dependencies. If you want to customize the process, then you can create a file named ILRepack.targets in your project folder. You can create it like shown below.

Example "ILRepack.targets"

<?xml version="1.0" encoding="utf-8" ?>
<Projectxmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- ILRepack -->
<TargetName="ILRepacker"AfterTargets="Build"Condition="'$(Configuration)' == 'Release' and '$(IsCrossTargetingBuild)' != 'true'">
<ItemGroup>
<InputAssembliesInclude="$(OutputPath)\ExampleAssemblyToMerge1.dll" />
<InputAssembliesInclude="$(OutputPath)\ExampleAssemblyToMerge2.dll" />
<InputAssembliesInclude="$(OutputPath)\ExampleAssemblyToMerge3.dll" />
</ItemGroup>
<ItemGroup>
<!-- Must be a fully qualified name -->
<DoNotInternalizeAssembliesInclude="ExampleAssemblyToMerge3" />
</ItemGroup>
<ILRepackParallel="true"Internalize="true"InternalizeExclude="@(DoNotInternalizeAssemblies)"InputAssemblies="@(InputAssemblies)"TargetKind="Dll"OutputFile="$(OutputPath)\$(AssemblyName).dll"
/>
</Target>
<!-- /ILRepack -->
</Project>

Configuration

You need to create the ILRepack.Config.props file in your project folder to configure the behavior of ILRepack.Lib.MSBuild.Task.

<?xml version="1.0" encoding="utf-8" ?>
<Projectxmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
</PropertyGroup>
</Project>

You can specify the following options inside the <PropertyGroup> element to configure the behavior of the ILRepack task.

Specify your custom Targets file path

If you don't want to add ILRepack.targets file in your project folder, then you can specify your custom targets file path as shown below.

<ILRepackTargetsFile>$(SolutionDir)ILRepack.targets</ILRepackTargetsFile>

Specify the Key File to use for signing

You can specify the path of the SNK file you want to use for signing your assembly as shown below. This configuration option only applies if you are using the default targets file provided in the NuGet package.

<KeyFile>$(ProjectDir)ILRepack.snk</KeyFile>

Specify whether to clear the directory after merging

If you are using the default targets file, then you may notice that it clears the Output directory after merging dependencies. You can turn this functionality off by setting ClearOutputDirectory to False as shown below.

<ClearOutputDirectory>False</ClearOutputDirectory>

Task options

OptionDescription
AllowDuplicateResourcesAllows duplicating resources in the output assembly.
AllowMultipleAllows multiple attributes (if type allows).
AllowedDuplicateNamespacesAllows the specified namespaces from being duplicated into input assemblies. Multiple namespaces are delimited by ",".
AttributeFileTake assembly attributes from the given assembly file.
CopyAttributesCopy assembly attributes.
DebugInfoEnable/disable symbol file generation.
DelaySignSet the key file, but don't sign the assembly.
ExcludeInternalizeSerializableDo not internalize types marked as Serializable.
InputAssembliesList of assemblies that will be merged.
InternalizeSet all types but the ones from the first assembly 'internal'.
InternalizeAssemblyInternalize only specific assemblies (list of assembly names without path or extension).
InternalizeExcludeIf Internalize is set to true, any which match these regular expressions will not be internalized. If Internalize is false, then this property is ignored.
KeyContainerSpecifies a key container to use.
KeyFileSpecifies a key file to sign the output assembly.
LibraryPathList of paths to use as "include directories" when attempting to merge assemblies.
LogFileSpecifies a log file to output log information.
MergeIlLinkerFilesMerge IL Linker file XML resources from Microsoft assemblies (optional). Same-named XML resources ('ILLink.*.xml') will be combined during merging.
NoRepackResDoes not add the embedded resource 'ILRepack.List' with all merged assembly names.
OutputFileOutput name for the merged assembly.
LineIndexationStores file:line debug information as type/method attributes (requires PDB).
ParallelUse as many CPUs as possible to merge the assemblies.
PauseBeforeExitPause execution once completed (good for debugging).
RenameInternalizedRename all internalized types (to be used when Internalize is enabled).
RepackDropAttributeName of an attribute (optional). Members in input assemblies marked with this attribute will be dropped during merging.
TargetKindTarget assembly kind (Exe|Dll|WinExe|SameAsPrimaryAssembly)
TargetPlatformDirectoryPath of Directory where the target platform is located.
TargetPlatformVersionTarget platform (v1, v1.1, v2, v4 supported).
UnionMerges types with identical names into one.
VerboseAdditional debug information during the merge that will be outputted to LogFile.
WildcardsAllows (and resolves) file wildcards (e.g., *.dll) in input assemblies.
XmlDocumentationMerge assembly XML documentation.
ZeroPeKindAllows assemblies with Zero PeKind (but obviously only IL will get merged).

About

MSBuild task for ILRepack which is an open-source alternative to ILMerge.

Topics

Resources

Stars

160 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages