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?
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.
IL Merge Instructions
- Add the business logic assembly to the plugin project.
- Add the MSBuild.ILMerge.Task NuGet package to the plugin project.
- ILMerge.props and ILMergeOrder.txt will be displayed in the plugin project after the MSBuild.ILMerge.Task NuGet package has been installed.
- Set the Copy Local property to true for the Business Logic Assembly Reference.
- 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.
- Build the solution.
- 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.
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.