-
Notifications
You must be signed in to change notification settings - Fork 198
spkl
Simple, No fuss, Dynamics 365 Deployment Task Runner
I've used the Dynamics Developer Toolkit since it was first released by MCS for CRM4! I love the functionality it brings however the latest version is still in beta, it isn't supported on VS2017 and there isn't a date when it's likely to be either (yes, you can hack it to make it work but that's not the point J).
Rather than using an add-in Visual Studio project type, I've been attracted by the VS Code style simple project approach and so I decided to create a 'no-frills' alternative that uses a simple json config file (and that can be used in VS2017).
- Deploy Plugins & Workflow Activities - Uses reflection to read plugin registration information directly from the assembly. This has the advantage that the plugin configuration is in the same file as the code. You can use the 'instrument' task to pull down the plugin configuration from Dynamics and add the metadata to your classes if you already have an existing project.
- Deploy Web Resources – deploy webresources from file locations defined in the spkl.json configuration. You can use the 'get-webresources' task to create the spkl.json if you already have webresources deployed. Generate Early Bound Types – Uses the spkl.json to define the entities to generate each time the task is run to make the process repeatable.
- Profile management – An optional profile can be supplied to select a different set of configuration from spkl.json. E.g. debug and release build profiles.
Let's assume you have a project in the following structure:
Solution
|-Webresources
| |-html
| | |-HtmlPage.htm
| |-js
| | |-Somefile.js
|-Plugins
| |-MyPlugin.cs
|-Workflows
| |-MyWorkflowActivity.cs
On both the Plugin and Workflows project, Run the following from the Nuget Console:
Import-Package spkl
This will add the spkl to the packages folder and the metadata CrmPluginConfigurationAttribute.cs that is used to mark up your classes so that spkl can deploy them. Some simple batch files are also included that you can use to get started.
If you already have plugins deployed, you can run the following command line in the context of the Plugins folder:
spkl instrument
This will prompt you for a Dynamics Connection, and then search for any deployed plugins and their matching .cs file. If the MyPlugin.cs plugin is already deployed it might end up with the following Attribute metadata:
[CrmPluginRegistration("Create","account",
StageEnum.PreValidation,ExecutionModeEnum.Synchronous,
"name,address1_line1", "Create Step",1,IsolationModeEnum.Sandbox,
Description ="Description",
UnSecureConfiguration = "Some config")]
A spkl.json file will be created in the project directly similar to:
{
"plugins": [
{
"solution": "Test",
"assemblypath": "bin\\Debug"
}
]
}
If you now build your plugins, you can then run the following to deploy
spkl plugins
You can run instrument for the workflow project using the same technique which will result in code similar to the following being added to your workflow activity classes:
[CrmPluginRegistration( "WorkflowActivity", "FriendlyName","Description", "Group Name",IsolationModeEnum.Sandbox)] …and then run the following to deploy:
spkl workflow
To get any currently deployed webresources matched to your project files you can run the following from the Webresource project folder:
spkl get-webresources /s:new
Where new is the solution prefix you've used
This will create a spkl.json similar to the following:
{
"webresources": [
{
"root": "",
"files": [
{
"uniquename": "new_/js/somefile.js",
"file": "js\\somefile.js",
"description": ""
},
{
"uniquename": "new_/html/HtmlPage.htm",
"file": "html\\HtmlPage.htm",
"description": ""
}
]
}
]
}
You can then deploy using:
spkl webresources
For Debug/Release builds you can define multiple profiles that can be triggered using the /p: parameter.
{
"plugins": [
{
"profile": "default,debug",
"assemblypath": "bin\\Debug"
},
{
"profile": "release",
"solution": "Test",
"assemblypath": " bin\\Release"
}
]
}
The default profile will be used if no /p: parameter is supplied. You can specify a profile using:
spkl plugins /p:release
Referencing a specific assembly rather than searching the folder If you have multiple plugins in a single deployment folder and you just want to deploy one, you can explicitly provide the path rather than using the folder search. E.g.
{
"plugins": [
{
"assemblypath": "bin\\Debug\MyPlugin.dll"
If you'd like to automatically add the items deployed to a solution after deployment you can use:
{
"webresources": [
{
"root": "",
"solution": "Test",
Perhaps you want to have a single spkl.json rather than multiple ones per project. You can simply add them all together:
{
"webresources": […],
"plugins": […]
}
Since the spkl.json configuration files are searched from the current folder, you can deploy multiple plugins/webresources using a single spkl call from a root folder.