Tuesday, 19 April 2011

Merge DLLs and EXEs with ILMERGE

You might have felt it to be too cumbersome to give your DLLs along with your EXEs when shipping your application. How cool would it be to give your user only ONE file which contains all your DLLs combined with your EXE? Well there is an awesome little freely available tool by Microsoft called ILMERGE which does just that. You can download it from here. After you install it, go to the command prompt and follow this sample syntax which  merges your program EXE with all your DLLs.

ilmerge /targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319 /target:winexe /out:CombinedFile.exe Initial.exe Library1.dll Library2.dll Library3.dll

ilmerge --> name of the tool

/targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319 --> The .NET framework version with witch you are working. (Version 4.0 in this case) and the Path where your .NET framework is installed so that we do not need to merge the system DLLs separately.

/target:winexe --> The type of EXE which you want. winexe=windows application & exe= console application.

/out:CombinedFile.exe --> The name of the file which will contain the combined EXE and the DLLs

Initial.exe --> The initial exe which does not have the DLLs merged with it.

Library1.dll Library2.dll Library3.dll --> The various DLLs which you want to merge with yout EXE.

No comments: