Have you ever faced this issue when you deployed plugins in MS Dynamics CRM?
“CRM cannot find the plugin assembly or one of its dependencies”
Here is a free tool from Microsoft to resolve the dependency issues of Assemblies. In simple words, ILMerge will create a capsule dll with all the dependency dlls inside in it.
IL Merge could be downloaded from the following link:
ILMerge is a tool to merge .NET assemblies into one dll. For instance, if you have business layer, configuration layer etc then you could merge all the dlls into a single dll using IL Merge. This is very useful when you develop plugins. We may need to include functionalities of other layers to our plugin. So if you use ILMerge you could merge those dlls along with your plugins dll. This avoids dependency issues while using plugins in MS Dynamics CRM.
In ILMerge you could specify the dlls to be merged. It’s very simple to use ILMerge.
Please ensure that the following are in place prior to executing these commands.
1) ILMerge.exe exists in the path provided in the command. 2) The output directory exists in the path provided in the command and also the file paths are valid
1) ILMerge.exe exists in the path provided in the command. 2) The output directory exists in the path provided in the command and also the file paths are valid
IL Merge could be implemented in 2 ways
1) Create a batch file and include the ILMerge code and later execute the batch file.
1) Create a batch file and include the ILMerge code and later execute the batch file.
Code snippet for the batch file:
"C:\Projects\MyProject\Library\ILMerge" /t:library /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 /copyattrs /keyfile:"C:\Projects\MyProject\Library\mykey.snk"
/out:"C:\Projects\MyProject\Plugins\OutputPluginsLibrary\ PluginsLibrary.dll" "C:\Projects\MyProject\Plugins\ bin\Debug\Entities.dll" "C:\Projects\MyProject\Plugins\ bin\Debug\Plugins.dll"
2) Include the ILMerge code in the BUILD EVENTS of the Class Library Project.
Place the following code snippet in the build event as shown in the screen shot
"$(SolutionDir)Library\ILMerge" /t:library /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 /copyattrs /keyfile:"$(SolutionDir)Library\mykey.snk" /out:"$(SolutionDir)Plugins\OutputPluginsLibrary\ PluginsLibrary.dll" "$(SolutionDir)Plugins\$(OutDir)Entities.dll" "$(SolutionDir)Plugins\$(OutDir)Plugins.dll"
This code execution will be done on a successful build.
Macros used:
$(SolutionDir) - The directory of the solution.
$(OutDir) - Path to the output file directory, relative to the project directory.
On a successful scenario, you could see a combined dll in the corresponding output directory. This dll will not cause any dependency issues when it’s deployed in Dynamics CRM Environment.
In my package solution, I have one plugin. Which refers the external dll. When I write the code, the classes of the external dll are available. Its built successfully. But when deploy the package above error comes. How ILMerge can help me?Say my plugin dll is A, and external is B, I merged A & B and made A at other location. How can I use the merged dll A in a solution?
ReplyDeletehello there, sorry for the delayed response. So my suggestion is to merge the necessary dlls using IL merge, and you could refer the above post or any other resource.
ReplyDeleteNow, as you recommended, imagine you dlls A & B. Also consider , 2 environments DEV and Production. So after using IL merge, you would get a merged dll. So you could register this dll to your DEV organization using plugin registration tool. After registering you could get the option to add the dll & plugin steps to your solution. You refer this post http://crmdm.blogspot.com/2011/03/plugin-deployment-in-crm-2011-best.html . Hence, when you import this solution to Production environment, you will have the plugins & steps inside the solution. Hope this helps.
Can you explain point No 2 Regarding Build Events in Detail .
ReplyDeleteWorked it out exactly in the manner you adviced but getting an error 9009
Intelepos offering business solution.
ReplyDeleteEPOS system for your shop
EPOS system for your Restaurants
EPOS system for your Bakery
EPOS system for your Takeaway
EPOS system for your retail store
intelepos.com
Website: https://intelepos.com/takeaways
Email: info@intelepos.com
Contact No: 0330 1134 157
IMpressive info
ReplyDelete