[Bonus] Setting Up Visual Studio Code for Dynamics 365 CRM Plugin Development
Before going further in our plugin journey, let’s make sure your environment is ready! This bonus guide walks you step by step through setting up Visual Studio Code for Dynamics 365 CRM plugin development—including both command-line (shell) and mouse-click (GUI) instructions. You’ll also learn how to write your first C# plugin, and discover some time-saving VS Code shortcuts and extensions.
1. Prerequisites
2. Installing Visual Studio Code & Extensions
A. Download and Install VS Code
Mouse Clicks:
Shell:
B. Install Required Extensions
Mouse Clicks:
Shell:
code --install-extension ms-dotnettools.csharp
code --install-extension jmrog.vscode-nuget-package-manager
code --install-extension ms-dotnettools.vscode-dotnet-runtime
code --install-extension eamodio.gitlens
code --install-extension microsoft-IsvExpTools.powerplatform-vscode
3. Creating a Plugin Project
A. Create a New .NET Class Library
Mouse Clicks:
B. Add Dynamics 365 SDK Assemblies
Mouse Clicks:
Alternative (Mouse):
Recommended by LinkedIn
4. Writing Your First C# Plugin
Mouse Clicks:
using System;
using Microsoft.Xrm.Sdk;
namespace MyFirstPlugin
{
public class SamplePlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)
serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
// Trace log
ITracingService tracingService = (ITracingService)
serviceProvider.GetService(typeof(ITracingService));
tracingService.Trace("SamplePlugin execution started.");
// Plugin logic
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity entity)
{
entity["description"] = "Updated by SamplePlugin at " + DateTime.UtcNow;
}
}
}
}
5. Building and Packaging the Plugin
Mouse Clicks:
6. Deploying the Plugin (Plugin Registration Tool)
Mouse Clicks:
7. Cool VS Code Shortcuts for Productivity
8. Recommended Extensions for Plugin Developers
9. VS Code Settings for C# Plugin Development
Add to your settings.json for an improved experience:
{
"editor.formatOnSave": true,
"csharp.format.enable": true,
"files.exclude": {
"**/bin": true,
"**/obj": true
}
}
10. Extra Tips
11. Further Reading
With both mouse and shell options, you can set up your environment your way! Let me know your favorite VS Code tips or extensions in the comments.
#Dynamics365 #PluginDevelopment #CSharp #VSCode #PowerPlatform #MSDyn365 #CRM #Developers #Productivity #CodingTips #VisualStudioCode
Helpful insight, Nithin Krishna.