Dynamic Crm Merge Assemblies
Now I want to share how to merge multiple assemblies in Dynamic CRM Environment. We used ILRepack as our merge tool because of the result is smaller compare to ILMerge.
For this tutorial, we will embed the command for merging in .csproj, so everytime we build our project. The result in the bin folder already merged.
- 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.15”

- After finished download and setup your nuget, save all of your project. Then open your .csproj with other editor and put the command for merging

<Target Name=”AfterBuild”>
<ItemGroup>
<InputAssemblies Include=”$(TargetPath)” />
<!– Framework –>
<InputAssemblies Include=”$(TargetDir)Niam.XRM.Framework.dll” />
<InputAssemblies Include=”$(TargetDir)Plugins1.dll” />
</ItemGroup>
<ItemGroup>
<KeyFile Include=”$(ProjectDir)key.snk” />
</ItemGroup>
<Exec Command=”$(ILRepack) /keyfile:@(KeyFile) /parallel /out:$(TargetPath) /lib:$(TargetDir) @(InputAssemblies -> ‘%(Identity)’, ‘ ‘)” />
</Target>
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 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 is it already merged or not:

This was originally posted here.

Like
Report
*This post is locked for comments