Dynamics CRM Plugin Development – Merging Assemblies: Why I choose ILRepack than ILMerge?

Do you ever need to merge multiple assemblies (DLLs) to deploy it in your Dynamics 365 Organization? Whatever the answer, I will tell you the background of why you should consider it. All of us must understand, as a programmer, we do some repetitive operations. Eg: general validation logic if the user in position “A”, don’t allow it to do any CRUD. Or you just want to make use of JSON Serializer in Newtonsoft. If you did not make/use a library for it, most likely you violate the DRY (Don’t Repeat Yourself) principle. It will cost you lots of problems in the future. But that is another topic. 🙂

Whenever someone asked about merging third party assemblies in our beloved Dynamics Community Forum, there was only one answer to it: ILMerge. First, I don’t hate ILMerge. But must be some explanation of why you choose ILMerge over others if there is an alternative to it (ILRepack). Here is my reason why I choose ILRepack.

For the demonstration, I will show you the solution that we will merge:

Solutions that we will merge: Demo.Plugins, Libs, Niam.Xrm.Framework

There are Project, Lib, and third-party assembly Niam.Xrm.Framework that we will merge.

Here is the original size of the assemblies in the bin folder:

Original size of the DLLs

If you have ILRepack.exe, here is the command:

ILRepack.exe /keyfile:key.snk /parallel /out:D:\ILRepack\Result\Demo.Plugins.ILRepack.dll Niam.XRM.Framework.dll Demo.Plugins.dll Libs.dll

If you have ILMerge.exe, here is the command:

ILMerge.exe /keyfile:key.snk /out:D:\ILMerge\Result\Demo.Plugins.ILMerge.dll Niam.XRM.Framework.dll Demo.Plugins.dll Libs.dll

This is the result of the ILRepack and ILMerge side by side:

Result after merged. ILRepack size more smaller compare to ILMerge.


As you can see, ILRepack result (2.794 KB) win (in size) compare to ILMerge result(3.177 KB).


4 thoughts on “Dynamics CRM Plugin Development – Merging Assemblies: Why I choose ILRepack than ILMerge?

    1. Hi Jonas, last time when I post it in LinkedIn, got someone mention need to use .NET Shared Project feature. It will directly merge into the assembly and is the way Microsoft recommend it. If got time, I’ll check on it and share it again.


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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.