ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly. It is freely available for use from the Tools & Utilities page at the Microsoft .NET Framework Developer Center.
NEW! You can now get it via NuGet. (Rob Reynolds also wrote a chocolately nuget for it.) Note that the version available on NuGet is a v4 application, so if you are merging v4 assemblies, you do not need to specify the /targetplatform option.
If you have any problems using it, please get in touch. (mbarnett _at_ microsoft _dot_ com) But first try reading the documentation!
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.
ILMerge is packaged as a console application. But all of its functionality is also available programmatically.
There are several options that control the behavior of ILMerge. See the documentation that comes with the tool for details.
The current version is 2.13.0307 (created on 7 March 2013). NOTE: There is no longer a version of ILMerge that runs in the v1.1 runtime.
ILMerge runs in the v4.0 .NET Runtime, but it is also able to merge assemblies from other framework versions using the /targetplatformoption. Please see the documentation. (However, it can merge PDB files only for v2 (and later) assemblies.)
Currently, ILMerge works only on Windows-based platforms. It does not yet support Rotor or Mono.
If you use ASP.NET v2.0, then it provides a tool (based on ILMerge) to combine assemblies created during precompilation. You can get more details from the ASP.NET web site.
Commercial use permitted:
The language of ILMerge's license has raised many questions. In a nutshell: commercial use is permitted, redistribution is not. Read the license carefully for full details since I am not (nor do I wish to be!) a lawyer.
Using .NET 4.5
|A Great Alternative to using ILMerge|
|If you cannot use ILMerge because you are trying to merge WPF assemblies, then here is a great way for you to get the same effect, courtesy of Jeffrey Richter: embed the dlls you want to merge as resources and load them on demand! In many ways, this is a better technique than using ILMerge, so I strongly urge you to check it out, even if ILMerge is working for your scenario.|
Merging WPF assemblies
ILMerge is not able to merge WPF assemblies. They contain resources with encoded assembly identities. ILMerge is unable to deserialize the resources, modify the assembly identities, and then re-serialize them. Sorry!