tsunami

log in
history

ilmerge

Luke Breuer
2010-06-22 16:16 UTC

Summary
Among other things, ilmerge (download) allows one to merge a dll into an exe so that instead of distributing two files and having the danger of FileNotFoundExceptions, things work simply.
Visual Studio build events
If you have the path to ilmerge.exe in your PATH variable, the following build events should work. Otherwise, you'll need to include the full path to ilmerge in the post-build script below.
Notes
  • if $(TargetPath) has spaces in it, then the below needs to be properly escaped
  • error messages arising from pre- and post-build events will show up in the output window (Ctrl-W, O for me)
  • using the VS debugger on a merged exe can fail in weird ways — I have not fully characterized this
pre-build
del $(TargetDir)*.pdb
(it's either VS or ilmerge that errors out if the .pdb file already exists)
post-build
I am assuming the dll is Mono.GetOptions.dll here.
move $(TargetPath) $(TargetPath).bak

REM it's important to use winexe if the exe is a windowed application, and exe if it is a console app

ilmerge /target:exe /out:$(TargetPath) $(TargetPath).bak $(ProjectDir)Mono.GetOptions.dll
del $(TargetPath).bak