Saturday, March 16, 2013

How to use ILMerge?

"A Zero Installation Technique for Portable Applications"

Build Portable in .NET C# App using ILMerge

I had a situation where I need to develop a portable application with simple installation. Finally I found a way make it zero installation!

If you are developing a portable Windows based application on .NET platform, you could benefit from IL Merging technique for your deployment.

IL Merge is a technique and a research product from Microsoft, to merge multiple DLLs and EXEs (.NET Assemblies) together to form a merged file (exe or dll). This way no separate DLL file is required.
Follow the below steps for merging an exe and dll associated with the project.

Download and install the ILMerge utility from Microsoft Website.

Step 1: Download ILMerge utility and install it in your machine

Step 2: Compile and Publish your Project to a folder (eg: C:\Publish\)

Step 3: Use the ilmerge command to merge the exe and dll files and output single exe file

ILMerge Command
Syntax (Simple*): ilmerge <input assembly 1> <input assembly 2> /out:<output file> /target:<dll|exe|winexe>

*For complete set of options and syntax refer ILMerge Documentation


C:\Program Files\Microsoft\ILMerge>ilmerge C:\Publish\MyProgram.exe C:\Publish\MyLibrary.dll /out:C:\Publish\MyWinApp.exe /target:winexe /ndebug

ilmerge – Command
MyProgram.exe – Output from the published folder
MyLibrary.dll – Any library used in the program
/target:winexe – We need to output a single exe file for Windows Platform
/output – Output folder and filename
/ndebug – To disable debug (.pdb file)

Note: Use the exe file first in the order of input files to get .exe as extension for output file.

Please share your experience and suggestions in the comments section below.


  1. I LOVE YOU!

    This was a perfect explanation on how to use this, it went through first try!

  2. ILMerge is looking for all dependent assembly such as those of System.Runtime.Serialization etc..
    Is there a way to avoid these


  3. Thank You! Tried for an hour to get the NuGet package working. Grabbed the .exe out of the package folder and then used this method and it worked the first time.


Share your comments