I have a Dynamics CRM 2016 On-Prem plugin, it connects to an ASP.Net web api endpoint secured with Azure AD. Thus I use the library Microsoft.IdentityModel.Clients.ActiveDirectory
However when I deploy the plugin, it fails to run on Dynamics CRM with the error:
Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=5.2.7.0
Originally I thought this was available when installing Windows Identity Foundation (WIF) on the Dynamics CRM servers. Perhaps I have mis-understood this.
I next tried to use ILmerge. I already use ILmerge for Newtonsoft JSON assembly and that works fine, but as soon as I add Microsoft.IdentityModel.Clients.ActiveDirectory the plugin assembly no longer registers and it fails with:
Unable to publish the project: Exception: Microsoft.Crm.CrmException: GetAssemblyMetadata: expected mdtAssemblyRef or mdtAssembly
How can this issue be overcome?