Hi! I'm here to help!
Chatbot Icon
Latest Highlights
šŸ† ITKnocks places 6th in the CRN Fast50
šŸŽ–ļø We are now Microsoft Solutions Partner - Business Applications
šŸ† ITKnocks places 6th in the CRN Fast50

Learn how to integrate NuGet packages in Dynamics 365 CRM plugins to

By Muhammad Asif

Introduction:

Dive into the intricate world of Microsoft Dynamics 365 CRM plugins with my latest article on C# Corner. This informative piece focuses on the critical aspect of adding NuGet Packages and incorporating dependent assemblies into Dynamics packages. Uncover the secrets of resolving the notorious ā€œcould not load assemblies or its dependenciesā€ issue with a step-by-step demonstration.

This guide not only troubleshoots the problem but empowers you to understand the process thoroughly, ensuring you don’t fall prey to common mistakes that lead to such issues. Elevate your Dynamics 365 CRM plugin development by mastering the art of handling NuGet Packages and dependencies seamlessly.

Avoid Direct Plugin Project Creation in Visual Studio

  • Never create a Plugin project directly from Visual Studio or any other IDE.

Utilize Microsoft PowerApps CLI

  • Always opt for creating your plugin project using Microsoft PowerApps CLI.
  • This ensures a standardized and reliable development environment.
  • It automatically creates a Nuget Package file that will be used to avoidĀ ā€œCould not load assemblies or its decenciesā€

Utilize Microsoft PowerApps CLI

  • Download and install Microsoft PowerApp CLI from this linkĀ Microsoft PowerApps CLI.Ā Complete the installation process
  • Download and install Nuget Package Explorer from this linkĀ Nuget Package ExplorerĀ open the Nuget Package Explore

Open CMD and run ā€œpacā€ command. You will get the information if it is successfully installed as following

Execute the following command to create plugin projectĀ 

  • Browse to the directory where you want to create the plugin project
  • Execute theĀ command on CMD to create plugin projectĀ ā€œpac plugin initā€

A plugin project will beĀ created at your desired location as follows

Click on the CS Proj file and open it in Visual Studio

By default, 2 files are automatically created when you create a plugin project as follows

I have added PgpCore Nuget package to my plugin project for Encryption and Decryption. You can have your own required nuget package as per your need.

Build your project

After a successful build, you will get the output result as follows

Browse the directory of your project

Open the fileĀ Plugin_Project.1.0.0.nupkg in Nuget Package Explorer by double clicking it

Now you can see that this nuget package file contains the information related to the added nuget package of PgpCore that we want to include in our plugin project package as follows. In your case, you can have the required nuget package that you want to addĀ 

Now open up plugin registration tool

Click to create new connection

Provide login details and login

Click to Register New Package

Browse to the directory where your nuget package file was created automatically when you build the project and import this file

Select the Command Data Service Default Solution and import it

Click on view and Display by package

Now your Plugin Project is successfully registered with all dependent assemblies and ready to use.

Conclusion:

In conclusion, navigating the intricacies of Microsoft Dynamics 365 CRM plugins demands a nuanced approach, especially when dealing with NuGet Packages and dependent assemblies. This article has delved into the critical process of resolving the persistent ā€œcould not load assemblies or its dependenciesā€ issue, offering a comprehensive, step-by-step demonstration.

By following the recommended best practices, such as avoiding direct plugin project creation in Visual Studio and harnessing the power of Microsoft PowerApps CLI, developers can establish a standardized and reliable development environment. The CLI’s automatic creation of a NuGet Package file not only streamlines the process but also acts as a preemptive measure against potential issues.

To further facilitate your journey, prerequisites such as downloading and installing essential tools like the Plugin Registration tool, Microsoft PowerApps CLI, and NuGet Package Explorer are highlighted. The guide emphasizes the significance of these tools in ensuring a smooth plugin development experience.

By adopting these practices and incorporating the suggested steps into your workflow, you not only troubleshoot existing issues but also fortify your understanding of the entire process. Take charge of your Dynamics 365 CRM plugin development, elevate your skills, and sidestep common pitfalls by mastering the art of handling NuGet Packages and dependencies seamlessly. Happy coding!Ā 

Let's Shape the
Future Together!

At ITKnocks, we are more than an IT consulting company; we’re your strategic partner in business evolution. With a global footprint and a passion for technology, we craft innovative solutions, ensuring your success. Join us on a journey of excellence, where collaboration meets cutting-edge IT expertise.