0

I have been tasked with bringing our 2008 CRM server into the modern age of Microsoft Dynamics 365 on-premises. I have got a plugin working and java script which is my first task and debugging/remote debug is working too. I can also make changes to the DLL and the changes work. However I am really concerned with how long winded the process to publish the DLL to the server is and wondered if am missing something. Watched quite a few videos, googled a lot but everyone seems to cover getting it working and that's it.

I note during Registration there is an option to select 'Disk' for the location of the DLL but this just crashes when i select it? so I am having to select 'Database'

Initial setup:

  • Build the plugin that adds a note 'A'
  • Copy the DLLs from bin\Debug onto server bin\assembly folder.
  • register plugin as Sandbox/Database
  • test and it works.

Currently my development workflow is:

  • modify the plugin code slightly to show 'B' instead of 'A'
  • rebuild the DLLs.
  • Copy the DLLs from bin\Debug to server bin\assembly folder.
  • test and it still shows 'A'

The ONLY way I have been able to get this working and it seems there must be an easier way:

  • rebuild the DLL's
  • Copy the DLLs from bin\Debug to server bin\assembly folder.
  • Open the registration
  • locate the DLL again
  • Tick the plugin selection boxes
  • click update selected plugins
  • test and it shows 'B'

This seems a real PIA if you need to rapidly change rebuild test which I suspect I will need to.

Is there an easier way?

David Makogon
  • 69,407
  • 21
  • 141
  • 189
DaveC
  • 63
  • 1
  • 8

3 Answers3

1

Plugin publishing and debugging can be a challenge for sure.

As far as publishing goes, I use the commercial 3rd Party Visual Studio extension XrmToolkit (no affiliation), which is not to be confused with the wildly popular community-supported XrmToolbox app.

XrmToolkit enables you to configure, build, and publish a plugin directly from Visual Studio. This greatly streamlines the process of publishing updates.

Microsoft used to have a Developer Extensions tool, and Jason Lattimer had one too, but I'm not sure if either of those are in active development anymore.

Another technique that I generally employ is to put the plugin code into a Visual Studio Shared Project, which I reference from both the plugin project and a Console App. I use the Console App to develop and debug before publishing the plugin. After the plugin goes live, I'll continue using the Console App to troubleshoot or build enhancements.

For Example:

///Shared Project
public class MyPluginApp
{
    private IOrganizationService svc;
    public MyPluginApp(IOrganizationService svc)
    {
        this.svc = svc;
    }

    public void Run(Account target)
    {
        //do stuff with the Target
    }
}

////Plugin
public void Execute()
{
    var app = new MyPluginApp(context.Service);
    app.Run(context.Target);
}

///Console App
public static void Main()
{
    var svc = new CrmServiceClient(connectionString);
    var target = getLastTouchedAccount(svc);
    var app = new MyPluginApp(svc); 
    app.Run(target);
}

Please also see this answer.

Aron
  • 3,877
  • 3
  • 14
  • 21
  • Thanks for your answer Aron. I will certainly take a look at XrmToolkit, I am already using it to locate the existing JScripts - didn't realised it integrated with VS though! I am also going to post another answer that i managed to dig up trawling google about how to get CRM Dev Tools working on VS2017. I now have this working and it is publishing and deploying in one click - nice ;) Thank you again I will Accept your answer. – DaveC Apr 24 '20 at 13:29
  • Thanks Dave, glad to help! And thanks for posting the instructions for installing the Developer Toolkit in VS 2017. I wrestled with that a bit before I moved to XrmToolkit years ago. XrmToolkit only installs in VS, so it might be XrmToolbox that you're using to locate existing JScripts... – Aron Apr 24 '20 at 14:12
  • Just to note "XrmToolBox" uses Pascal Case naming convention :) – Jordi Apr 24 '20 at 20:53
0

Whilst the method I am using above is workable its downright painful and prone to mistakes. I found that restarting the IIS server also works but navigating to and restarting it is really not a viable option.

I found that there used to be a developers tool as mentioned by Aron called 'Microsoft Dynamics 365 Developer Toolkit' which you can download from MS here

For Visual Studio 2017 you will need to edit the vsix:

  • Extract with 7Zip or rename as zip and extract to a folder.
  • in the folder you will find extension.vsixmanifest
  • edit the file and replace the lines

InstallationTarget Version="[11.0,14.0]"

with:

InstallationTarget Version="[11.0,15.0]"

  • this tells the manifest to allow install on 2017
  • rezip the contents of the folder (NOT the folder)
  • rename the zipped file as .vsix
  • install the vsix
  • ignore the warning and finish installing.

You should now have a new Dynamics CRM section in your New Project section of VS2017.

You will need to go into 'Tools > Options > Dynamics 365 Development Toolkit > Tool Paths' and set the path to your CRMSDK bin and Tools/PluginRegistrationTool folder.

To create a new project:

  • New Project
  • Select the "New Visual Studio Solution Template for Dynamics 365"

To add a new Account entity for example:

  • VS2017 > CRM Explorer
  • Right click Account > Create Plug-in

Now unless i have forgotten something when you Right click the 'Package' and choose Deploy it will deploy to your CRM server ;)

Regards, DaveC

tip 1: The CRM SDK pointed to by our 365 server actually pointed to the 2015 SDK from microsoft. Caused some consternation on my behalf as the toolkit requires 8.0 upwards ;)

DaveC
  • 63
  • 1
  • 8
  • This works but... With a plugin, satellite DLL's are not supported. And I can't find a way of easily merging satellite DLL's into it eg. your Accounts.dll for example. ILMerge is no longer supported for CRM Dynamics by Microsoft (from what I've read). And for me a shared project in VS2017 whilst it compiled did not work and just threw an error 'illegal characters in path'. There aren't any illegal chars in any of the paths that i can see in any of the projects plugin/shared/package. I am still investigating! It really really should not be this time consuming ms! – DaveC Apr 28 '20 at 13:21
  • Thanks for the update. Sucks that the shared project is having an issue. It is possible to get working. "It really really should not be this time consuming ms!" - I have certainly felt the same way at times. – Aron May 01 '20 at 21:35
  • Over the last few days of investigating i never did find a solution to wrapping DLL's into or accessing them cleanly on the CRM server. I suspect this is because plugins are intended for simple manipulations of the front end forms etc and not really for implementing back end processes. I suspect the cloud is being pushed as the solution so i used a WCF service to do the back end work. Also you can't pop a confirmation message form/dialog from a Plugin only from Java. Learning as I go! – DaveC May 04 '20 at 07:22
  • Hi Dave, Generally speaking, plugins are for adding custom logic to the back end platform. JavaScript is for adding custom logic to the front end web client. MSFT definitely promotes the cloud so it's cool that you used a WCF service. You might also want to look into an Azure-aware Plugin, which sends the plugin context to an Azure endpoint for processing. Of course Power Automate is huge now too. – Aron May 11 '20 at 12:00
0

That's the dev workflow I used to do many years ago involving manual deployment and testing of plugins. Nowadays I use a much more modern and efficiet way of developing and testing plugins using TDD (Test Driven Development).

Traditional manual workflow involves:

  • 1) Make changes to plugin
  • 2) Deploy plugin via Plug Registration or other VS extensions
  • 3) Test plugin manually in the target environment / attach remote debugger / profiler
  • 4) Repeat

That's a very time consuming workflow.

With a more automated dev workflow it becomes instead:

  • 1) Make changes to plugin
  • 2) Debug / test locally
  • 3) Repeat
  • 4) Push your changes, and let the CI trigger build and release your plugin

Or if following TDD strictly:

  • 1) Add / update any necessary unit tests based on the requirements, this will cause your plugins to fail, since that plugin doesn't have an implementation logic that validates those requirements yet
  • 2) Update your plugin code so the unit tests pass
  • 3) Refactor your code with confidence (making sure unit tests still pass)
  • 4) Push your changes
  • 5) Let the CI build and release automation trigger

The main difference is that with the TDD approach, your dev & test feedback loop is much more quicker, and you only (usually) need a single deployment step at the end, which can also be automated.

You can also make use of existing open source frameworks that allows mocking most of the interfaces in the Microsoft SDK for you like FakeXrmEasy (which I'm the author of).

Hope this helps

Jordi
  • 1,460
  • 9
  • 9
  • @Jodi thanks for your insight. I am aware of TDD development and FakeXtmEasy sounds interesting. My main problem at the moment though is that i simply can't build a working plugin with satellite dlls included. Why this is so hard i have no idea! I am considering investigating other avenues such as WCF as the who deploying a plugin thing seems flawed and problematic. – DaveC Apr 28 '20 at 13:25
  • If you own the .dll's (they're internal in your org) better option would be to push them a source code NuGet package, and consume them from the main plugin in my mind. Otherwise ILmerge them however is no longer "supported". The other option is adding a web service as you suggested, but then we're introducing another network element which might be a prob... – Jordi Apr 30 '20 at 02:53