Reputation: 688
Here is my scenario: we use Dynamics CRM Online 2015 Update 1. For this purpose, we have to develop some plugins. I use the latest version of the CRM SDK (v8.0.0). And we use Visual Studio Team Services + Visual Studio 2015 Enterprise Edition.
My plugins have some dependencies, for instance on Newtonsoft.Json.
I found out that to be able to deploy my plugins, I have to use ILMerge so that Newtonsoft.Json is merged to my plugin DLL and can be used by it once deployed. The method is described here: http://nicknow.net/dynamics-crm-ilmerge-dll-plugin/ And so far, it works fine!
The downside of this method is that the assemblies Microsoft.Crm.Sdk.Prox, Microsoft.Xrm.Sdk and Microsoft.IdentityModel must not be included in the merged assembly. To do that, I have to set their property "Copy local" to False.
That's fine for plugin deployment. But when I check-in my plugins, the build of VSTS fails because it is not able to find the 3 assemblies having Copy local set to False.
So my question is, in your opinion what would be the best way to handle this? Is it possible for example to add a script before the build that would set Copy local to True? How? Or if you could think of any other idea, please feel free :)
Upvotes: 1
Views: 960
Reputation: 31
The VSTS build should not fail on the references. I have a build definition with a similar structure using ILMerge.Task which runs perfectly fine. The best thing to do is follow these steps:
A file called 'ILMerge.props' will be added to your project. You should set two properties in this file:
<ILMergeAllowMultipleAssemblyLevelAttributes>true</ILMergeAllowMultipleAssemblyLevelAttributes>
<ILMergeCopyAttributes>true</ILMergeCopyAttributes>
These properties make sure that duplicate attributes over different assemblies are handled properly.
Upvotes: 1
Reputation: 7918
Do not use Microsoft v8 CRM-assemblies; these are part of Dynamics CRM 2016. For CRM 2015 you need v7.
Add NuGet-package Microsoft.CrmSdk.CoreAssemblies to your plugin project; it helps avoiding build problems.
Add NuGet-package ILMerge to the solution. It's installed at a default location.
Add a batch script to your project that is run as a post-build step. Your script should contain a merge step similar to this: "%SOLUTIONDIR%packages\ILMerge.2.14.1208\tools\ILMerge" /log:ILMerge.log /keyfile:"%KEYFILE%" /targetplatform:v4,"%PLATFORMDIR%" /out:tmp_merge\%PROJECTBINARY%.dll %PROJECTBINARY%.dll Newtonsoft.Json.dll
Upvotes: 2
Reputation: 2087
When using Ilmerge as command line, you can choose which dlls to include. In my projects I usually:
Upvotes: 1