Posted by: bearc0025 | April 9, 2009

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 Files\Microsoft\ILMerge\ilmerge” /out:$(TargetDir)MyApp.exe $(TargetDir)MyApp_build.exe $(TargetDir)LitJson.dll $(TargetDir)PdfSharp.dll

Pre/Post Build Macro Help

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: