Create XrmToolBox Plugin – Part 2: Debug XrmToolBox Plugin

In this blog, I will describe how to debug the XrmToolBox plugin project which we created in Part 1. If you have not read my first blog I recommend you read it first.

This is my second blog in the series of 4 blogs, below are the links to other blogs

  1. Create XrmToolBox Plugin – Part 1: Set-up Visual Studio and create a basic plugin
  2. Create XrmToolBox Plugin – Part 3: Package your plugin
  3. Create XrmToolBox Plugin – Part 4: Setup build definition release for CI and CD

Prerequisites:

  1. Visual Studio 2017.
  2. You have created the visual studio project and configured as mentioned in Part 1 of this series.

Step 1: Add post-build command to your VS project to create a Plugin folder and copy your plugin assemblies to this folder.

if $(ConfigurationName) == Debug (

IF NOT EXIST Plugins mkdir Plugins

move /Y SampleXrmToolBoxPlugin.dll Plugins

move /Y SampleXrmToolBoxPlugin.pdb Plugins

)

Step 2: Configure XrmtoolBox.exe to start on debugging by setting the XrmToolBox.exe path in “Start external program”. This exe can be found at “<<your plugin project location>>\bin\Debug\XrmToolBox.exe”. If you don’t see this exe in debug folder, just rebuild your plugin.

/overridepath:. – it will tell XrmToolBox.exe to look for the plugin in the debug folder of your project

/connection:”<<crm connection name>>” – the name of the CRM connection you have saved in XrmToolBox. It saves debugging time by automatically connecting to CRM instance.

/plugin:”<<plugin name>>” – the Name of your plugin as you have specified in “MyPlugin.cs” file

Step 3: Add XrmToolBox.exe.config file

You need to add this file to your project and set its property “Copy to Output Directory” to “Copy always”. This file can be found at

  1. “<<your plugin project location>>\packages\XrmToolBoxPackage.1.2018.6.25\lib\net462. If you don’t find config file here go to next step. This path will change as per XrmToolBox package version installed on your machine and .net version.
  2. Download XrmToolBox (same version as XrmToolBoxPackage )from here and copy its config file in your project.

Step 4: copy dependencies to XrmToolBox.exe.config

  1. Copy all missing dependencies from “app.config” file to “XrmToolBox.exe.config”.
  2. If you get any missing dependencies error when you debug your project, it needs to be added here.

Now you are all set to debug your project.

Hope it helps .

Reference: https://github.com/MscrmTools/XrmToolBox/wiki/Debug-your-plugins-during-development

2 thoughts on “Create XrmToolBox Plugin – Part 2: Debug XrmToolBox Plugin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s