Skip to content

ILMerge – compile your DLLs into your EXE (C#)

ILMerge – Microsoft Research

If you want to compile your DLLs into your C# output EXE, use this command-line too called ILMerge. There are good docs for the API and such and there’s command line help, but the core syntax is:

C:ilmerge /out:<filename> <primary assembly> [<other assemblies>…]

NOTE: Your out filename can’t be the same as your primary assembly.

Usage: ilmerge [/lib:directory]* [/log[:filename]] [/keyfile:filename [/delaysig
n]] [/internalize[:filename]] [/t[arget]:(library|exe|winexe)] [/closed] [/ndebu
g] [/ver:version] [/copyattrs [/allowMultiple]] [/xmldocs] [/attr:filename] [/ta
rgetplatform:<version>[,<platformdir>] | /v1 | /v1.1 | /v2] [/useFullPublicKeyFo
rReferences] [/wildcards] [/zeroPeKind] [/allowDup:type]* [/union] [/align:n] /o
ut:filename <primary assembly> [<other assemblies>…]

Download ILMerge

I created a post-build event like this (I made my output exe from VS to be MyApp_build so that the ilmerge out filename cd be what I really wanted):

“C:Program FilesMicrosoftILMergeilmerge” /out:$(TargetDir)MyApp.exe $(TargetDir)MyApp_build.exe $(TargetDir)LitJson.dll $(TargetDir)PdfSharp.dll

Pre/Post Build Macro Help