Sometimes developers want to reference third party assemblies when creating Dynamics CRM plugins. Or if you are like me, you want to separate your logic and plugin code into separate Visual Studio projects. Deploying third party assemblies to CRM Dynamics Online is impossible, and IL Merge makes this possible.

What is IL Merge?

“IL Merge is a utility for merging multiple .NET assemblies into a single .NET assembly” and can be downloaded from here. More information regarding IL Merge can be found here.

The Visual Studio Solution

The visual studio solution contains a business logic project and a plugin project. The plugin project uses the business logic project.

business-logic

IL Merge Instructions

  1. Add the business logic assembly to the plugin project.

add-business-logic-assembly

  1. Add the MSBuild.ILMerge.Task NuGet package to the plugin project.

msbuild-ilmerge-task-nuget-package

 

  1. ILMerge.props and ILMergeOrder.txt will be displayed in the plugin project after the MSBuild.ILMerge.Task NuGet package has been installed.

ilmerge-props-and-ilmerge-txt

  1. Set the Copy Local property to true for the Business Logic Assembly Reference.

business-logic-reference-properties

  1. Set Copy Local property to false for all Assemblies that are not to be merged into the plugin assembly including Microsoft.Xrm.Sdk and Microsoft.Crm.Sdk.Proxy.

NOTE: all assemblies that are copied to the bin directory will be merged into the plugin assembly.

  1. Build the solution.
  2. Open the Bin directory, you will find only the plugin assembly. All other assemblies that had the Copy Local property set to true have been merged into the Plugin assembly.

il-merge-with-dynamics-crm-plugins

 

Now the assembly can be deployed to CRM using the plugin registration tool.

In summary, this blog details the instructions for using IL Merge to allow third party assemblies to be used by a Dynamics  CRM plugin. Alternatively, IL Merge can be used to separate business logic and plugin logic into individual Visual Studio projects.