The XrmToolBox is one of the greatest community driven tool for Dynamics 365 CE. It supports several Dynamics CRM versions and is OnPremise and Online capable.
There are also several Plugins available, written by open minded people. If something is missing, you can even write and publish your own Plugin to the community. This happens in several steps.
Setup new Visual Studio Project
This is already well described in this article: https://www.xrmtoolbox.com/documentation/for-developers/install-xrmtoolbox-plugin-project-template/
To be able to debug your Plugin inside the XrmToolBox, you just need to follow the following steps: https://www.xrmtoolbox.com/documentation/for-developers/debug/
Prepare your Release
Releasing your Plugin happens through NuGet. Here the documentation is lacking a little bit.
First of all you need to add the “NuGet.CommandLine” to your project file, using the inbuilt NuGet Package Manager in Visual Studio.
After this you now have to generate a nuspec-file. The benefit of generation is, that it already contains placeholder. We want to have this place-holder, so that you don’t need to maintain the release details always in two locations (assembly.cs and your projectfile.nuspec).
To generate the file, open the Package-Manager-Console through (View –> Package Manager Console). You might need to navigate into your projectfolder, where your *.csproj is located.
It will generate a new *.nuspec with a lot of placeholder. If it fails, close Visual Studio and reopen it. After adding NuGet.CommandLine, sometimes not all paths are set properly.
Fine-tune the *.nuspec file
Open the nuspec file and remove all placeholder, that are static with the text you want. I only left the version number as a variable like this.
Make sure you add the following into the <tags> node:
XrmToolBox Plugin %yourPluginName%
Reference your files
Be aware, that you are using the Debug builds only for debugging and testing. If you want to release, you should use the Release build. Therefor you have to point to your release output. In my case I only have the plugin dll. So it looks like this. I have to make sure, that my output is placed into the Plugins-folder on the target. My project is targeting to .Net 4.6.2.
Make sure, you add the decency to the XrmToolBox-Version you are using, when you developed your plugin.
Finally – Automate the nuget file build on release
We wanted to have the version number taken from the Assembly version of our dll. Therefor we have to modify the *.csproj file on our own. Just open it and do the following modifications.
Search for “<Target Name=”AfterBuild”>” in your current file. This should be inside a commented section, if you don’t have done any manual changes yet.
After the comment add the following section:
<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'"> <GetAssemblyIdentity AssemblyFiles="$(TargetPath)"> <Output TaskParameter="Assemblies" ItemName="myAssemblyInfo" /> </GetAssemblyIdentity> <Exec Command="nuget pack .\CRMP.XTBPlugin.SystemComparer.nuspec -Properties version=$([System.Version]::Parse(%(myAssemblyInfo.Version)).ToString(4))" /> </Target>
This section will now always execute, after you build your project in Release configuration only.
GetAssemblyIdentity retrieved the assembly information of the output. In our case it is the dll. So we can access the information we have entered into our assembly.cs file.
The second line will create the nupkg-file we need and injects the assembly version from our assembly into the package. So we only have to change the version number once in our project using the assembly version number.