Marko Apfel - Afghanistan/Belgium/Germany

Management, Architecture, Programming, QA, Coach, GIS, EAI

  Home  |   Contact  |   Syndication    |   Login
  168 Posts | 2 Stories | 130 Comments | 4 Trackbacks


Twitter | LinkedIn | Xing

Article Categories


Post Categories



Enterprise Library


SQL Server


Offen also a simple application references some other assemblies. In those cases for a deployment all of these assemblies are needed. Instead giving the customer a bunch of all, with ILMerge you can bundle all assemblies in one.

To support the merge-process in a post built step in my solution tree is a folder named Build which contains tools for the build-process. One of these tools is ILMerge:

Next thing we need is a simple batch (ILMerge.bat) in the project which calls ILMerge:


The ILMerge call is simple. First we copy the original AedSicad.UT.Application.Egm.Replication.exe to a temp.exe, because we want have the new bundled EXE under the same name. Then we use ILMerge to build the bundle. In a last step the temp.exe should be deleted:

   1: ECHO parameter=%1
   2: CD %1
   3: COPY AedSicad.UT.Application.Egm.Replication.exe temp.exe
   4: ..\..\Build\ILMerge\ILMerge.exe /out:AedSicad.UT.Application.Egm.Replication.exe temp.exe AedSicad.UT.Application.Egm.Replication.Engine.dll EsriDE.ArcGIS.Commons.Logging.dll log4net.dll
   5: DEL temp.exe

The last step is the post build command:

   1: $(ProjectDir)ILMerge.bat $(OutDir)


The result is AedSicad.UT.Application.Egm.Replication.exe which contains all referenced assemblies. In this case the log4net assembly and an own wrapper for logging-stuff.

posted on Saturday, November 1, 2008 11:47 AM


# re: Using ILMerge in a post build step 10/12/2010 1:33 PM R. Schreurs
Very useful, but at first I ran into:
The command "<path>\ILMerge.bat bin\" exited with code 9009
This code is returned by VS.Net, trying to execute the post-build event, not by ILMerge.
This happened in VS.Net 2008 and was caused spaces in the full path of $(ProjectDir). I fixed it by modifying the command line to:
"$(ProjectDir)ILMerge.bat" $(OutDir)
Note the double quotes are only around the path of the batch file and exclude the command line parameter.

# re: Using ILMerge in a post build step 2/2/2011 10:32 AM mosquitoes trap
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your posts. Any way I'll be subscribing to your feed and I hope you post again soon..

# re: Using ILMerge in a post build step 2/3/2011 1:25 PM
It’s really a nice and helpful piece of information. I’m glad that you shared this helpful info with us. Please keep us informed like this. Thanks for sharing.

# re: Using ILMerge in a post build step 2/16/2011 8:36 AM Miket
I have also used the same technique to pass back a offsetting so that I know what timezone the user is in and I can show the dates correctly to users in other timezones if necessary.
superior essays

# re: Using ILMerge in a post build step 3/7/2011 9:51 AM Wicked Tickets
Really valuable written content. the information that you shown is amazing and many prominently i liked the way you provided things here. Extremely, the concept is real time applicable and as per the current demand of the internet user society.

# re: Using ILMerge in a post build step 3/11/2011 7:33 AM small business grants for women
I just read through the entire article of yours and it was quite good. This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post.

# re: Using ILMerge in a post build step 3/11/2011 1:22 PM Language translation
Aw, this was a really quality post. In theory I’d like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate a lot and never seem to get something done…

# re: Using ILMerge in a post build step 3/12/2011 2:08 AM wholesale red bull hats

# re: Using ILMerge in a post build step 3/23/2011 10:35 AM hair restoration products
this is something very interesting...
thanks for the post and keep sharing....

# re: Using ILMerge in a post build step 4/9/2011 5:02 PM IELTS Preparation Course
Thanks for providing me this complete solution.

# re: Using ILMerge in a post build step 6/9/2011 8:40 AM burtonjuelfs
I have found this your post because I have been searching for some information about it almost three hours. You helped me a lot indeed and reading this your article I have found many new and useful information about this subject.
stop smoking remedy

# re: Using ILMerge in a post build step 7/5/2011 1:29 PM prevent snoring
Thanks for one's marvelous posting! I definitely enjoyed reading it, you will be a great author.I will remember to bookmark your blog and will often come back later on. I want to encourage that you continue your great posts, have a nice morning!

# re: Using ILMerge in a post build step 7/20/2011 4:07 PM Ken van Riel
Past this in the post-build and you dont need to make a .bat file.

MKDIR Merge\
"C:\Program Files\Microsoft\ILMerge\ILmerge.exe" /target:library /out:Merge\WSFClient.dll Microsoft.ApplicationBlocks.Data.dll WSFClient.dll

# re: Using ILMerge in a post build step 7/20/2011 5:17 PM Marko Apfel
I prefer batch files, because this allows me to run this step without visual studio. It gives me more flexibility.
This principle grows up with the time. First steps are gone with post-build events too.

# re: Using ILMerge in a post build step 11/2/2011 4:15 PM Frank
If you get a 9009, don't forget the quotes around the ILmerge.exe call... just found that out :)

great post, works as it should work!

# re: Using ILMerge in a post build step 11/14/2011 8:18 AM raghu
My solution/Project name is 'AuditTool' and in this I am using log4net. I need to create the application exe that includes log4net.

The below code is included in the batch file

..\..\ILMerge\ILMerge.exe /out:AuditTool.exe log4net.dll

And the post build event is
$(ProjectDir)ILMerge.bat $(OutDir)

But I am getting error -> 'The command "D:\AuditTool\ILMerge.bat bin\Debug\" exited with code 1'

# re: Using ILMerge in a post build step 3/19/2012 8:28 AM website design bangalore
Thanks for sharing such a nice post

# re: Using ILMerge in a post build step 3/22/2012 3:50 PM Roller blinds
Thanks for sharing such a nice post

# re: Using ILMerge in a post build step 4/20/2012 3:40 PM Nick
Thank you so much for posting this. I estimate that I have half a day of just trying to figure out a logical solution and another few hours trying to figure out how to use ILMerge effectively. This is a huge help.

Post A Comment