Dynamics Crm Merge Assemblies

Now I want to share how to merge multiple assemblies in Dynamics CRM Environment. We used ILRepack as our merge tool because the result is smaller compare to ILMerge.

For this tutorial, we will embed the command for merging in .csproj, so every time we build our project. The result in the bin folder is being merged already.

  1. In your current project, right-click and add NuGet package > search ILRepack and installed it. Or you can open Nuget Package Manager and install it using “Install-Package ILRepack -Version 2.0.15ilrepack-installation-nuget
  2. After finished download and set up your NuGet, save all of your projects. Then open your .csproj with other editor and put the command for mergingcsproj-ilrepack

Here is the command:

<Target Name="AfterBuild">
<InputAssemblies Include="$(TargetPath)" />
<!-- Framework -->
<InputAssemblies Include="$(TargetDir)Niam.XRM.Framework.dll" />
<InputAssemblies Include="$(TargetDir)Plugins1.dll" />
<KeyFile Include="$(ProjectDir)key.snk" />
<Exec Command="$(ILRepack) /keyfile:@(KeyFile) /parallel /out:$(TargetPath) /lib:$(TargetDir) @(InputAssemblies -> '%(Identity)', ' ')" />

You can put all the needed assemblies in that configuration and don’t forget to put the .snk file also. For this example I put the key.snk.

When you build your project, you will notice in your output will have this result:


For checking, you can open your DLL using ILSpy to check if is it already merged or not:


2 thoughts on “Dynamics Crm Merge Assemblies

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 )

Connecting to %s

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