Insights hero banner (short)

Insights

Bringing our best ideas and thinking to you.

  • Blog Post
  • CRM
  • CRM
  • Microsoft Dynamics CRM

Blog Post

November 11, 2016

Share this page:

Using ILMerge to Include Referenced Packages in Microsoft Dynamics CRM Plugins

By Shawn Lautebach

When writing Plugins for CRM, it is handy to include and use libraries from the NuGet repository, or your own shared library project. But with CRM a plugin is self contained within its assembly and to reference any other assemblies you will need to upload the additional assemblies to all the CRM server GAC (Global Assembly Cache). This can be a nightmare to manage or may not even be technically possible.

A solution to this is to use ILMerge a utility for merging multiple .Net assemblies into on single .Net Assembly. You can download the tool from Microsoft here: https://www.microsoft.com/en-us/download/details.aspx?id=17630. Or you can add a NuGet package to your project 'MsBuild ILMerge task' (https://www.nuget.org/packages/MSBuild.ILMerge.Task/).

To ensure that the CRM SDK assembly references are not merged, right click on each assembly reference and click properties. Change the property: 'Copy Local' to 'false'. This will ensure that these assemblies are not merged into your plugin assembly.