ILMerge
Michael Barnett
Programming Languages and Methods
Microsoft Research
Copyright (C) Microsoft Corporation. All rights reserved.
1 Introduction
This document describes the ILMerge utility which merges multiple .NET assemblies
into a single assembly. However, some .NET assemblies may not be able to be merged
because they may contain features such as unmanaged code. I would highly recommend
using peverify (the .NET Framework SDK tool) on the output of ILMerge to guarantee
that the output is verifiable and will load in the .NET runtime.
ILMerge is packaged as a console application. But all of its functionality is also
accessible programmatically. Note that Visual Studio does allow one to add an
executable as a reference, so you can write a client that uses ILMerge as a library.
ILMerge takes a set of input assemblies and merges them into one target assembly. The
first assembly in the list of input assemblies is the primary assembly. When the primary
assembly is an executable, then the target assembly is created as an executable with the
same entry point as the primary assembly. Also, if the primary assembly has a strong
name, and a .snk file is provided, then the target assembly is re-signed with the specified
key so that it also has a strong name.
Note that anything that depended upon any of the names of the input assemblies, e.g.,
configuration files, must be updated to refer instead to the name of the target assembly.
Any Win32 Resources in the primary assembly are copied over into the target assembly.
There are many options that control the behavior of ILMerge. These are described in the
next section.
2 Public Interface
The public interface for ILMerge is defined in the ILMerging namespace as the class
ILMerge.
namespace ILMerging;
public class ILMerge { }
To use this class programmatically, just create an instance using the default (nullary)
constructor. There are several properties and methods which are used to affect the
behavior of the merging. The method Merge() is called to actually perform the merging.