Merging DLLs in the new csproj project format (excluding specific NuGet packages)


There’s no breakthrough in this blogpost… It’s just to show you how does the new .csproj look like, what basic things can be done in msbuild and how-to setup ILRepack for common data service painlessly.

ILMerge vs. ILRepack

Let me start with this statement: It’s not supported to use ILMerge (or any other tool) for merging assemblies for CDS. But it’s not forbidden either…
A lot of you – CDS developers – are using ILMerge. It’s easy to use and works as expected. But it has one flaw. I couldn’t setup ILMerge with the new .csproj format. I think, that it’s possible, but this was impulse to move to ILRepack, which I was sure, that it supports the new .csproj format and it’s opensource replacement of ILMerge. You can check it out on GitHub.

How to correctly setup ILRepack for your libraries with codeactivities and plugins

This is something that can be done with some research quite easily, there’s nothing hard/special, that you need to know. But I couldn’t find guide that solved all my issues, so I write this blogpost with all steps that I had to apply. I’ll try to explain them, so you can understand how it works.
Let’s get to it.

Before we start tweaking our .csproj, you need to install ILRepack nuget package to your project.

Now it’s just about adding some parts into .csproj:

You start with something like this – new .csproj format. Now you can add ILRepack element:

Replace all values in angle brackets in “Exec” element. My result looks like this:

But this won’t work, because this would also merge Microsoft.CrmSdk.CoreAssemblie and Microsoft.CrmSdk.Workflow from nuget packages into my main assembly. If we would do this, plugin registration tool wouldn’t let us register it (ambiguity).
So we need to reference them, but not merge them. We can achieve this by:

As I said in the beginning – no breakthrough, but something like this would help me a lot!

Leave a Reply