Context: I'm writing a CRM Plugin, trying to use a recent version of RestSharp. I'm trying to use ILMerge to merge in RestSharp (and its dependencies such as the listed error) into the Plugin DLL.
Merged assemblies: ... source\repos\MyCRMVSSolution\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll; ...
error : Unresolved assembly reference not allowed: System.Runtime.CompilerServices.Unsafe.
See above, the "merged assemblies" command shows that it knows where the file is under /packages/, and it knows to try to Merge it. Yet it says it's an unresolved reference.
Why could it come back saying "Unresolved" for it? Not sure what to even review or debug. It's apparently reading it right where I want it to, under packages. But somehow not.
Using the Nuget package MSBuild.ILMerge.Task
, with default/OOTB configuration.
Downgrade to a RestSharp version that has 0 dependencies. That way, you'll avoid ILMerge trying to find and manage all its dependencies.
Example RestSharp Nuget package that has 0 dependencies:
<package id="RestSharp" version="106.10.1" targetFramework="net471" />
Comments:
Overall with ILMerge for CRM Plugins, it's wise to put as little dependence on it as possible to do the right thing... limit 3rd party DLL's that need to be Merged as much as possible. Take that very seriously to avoid wasted battles with ILMerge.