Custom Controls Framework - Solution Packager

– 2 Minutes

The Solution Packager tool for Dynamics 365 has been around for a few years, and Microsoft has kept it updated as they released new features/solution component types. However, despite adding support for some of the new features found in V9, they have not yet added support for Custom Controls. This can be fixed pretty easily by creating a custom plugin for the tool.

Note: creating/using plugins for the Solution Packager is probably unsupported (since there is no official documentation).

I have published the plugin for parsing Custom Controls on GitHub. I won't go through the code in detail here -- you can check the code out on GitHub if you're curious -- but I will show how to create a very basic plugin since, as far as I know, no one has done this yet.

The process is actually quite simple. First, you need to create the plugin class. There is no official SDK for the Solution Packager tool, so you have to reference the SolutionPackager executable in the project instead of a DLL. The executable has an interface called IPackagePlugin with four methods: BeforeRead, AfterRead, BeforeWrite, and AfterWrite.

You can use this interface to create a very simple plugin that just writes a message to the console after it is done writing the files (either to disk or the zip file).

namespace SolutionPackager.Plugins
    using Microsoft.Crm.Tools;
    using Microsoft.Crm.Tools.SolutionPackager;
    using System.Diagnostics;

    public class Sample : IPackagePlugin
        public void BeforeRead(PluginContext pluginContext) { }

        public void AfterRead(PluginContext pluginContext) { }

        public void BeforeWrite(PluginContext pluginContext) { }

        public void AfterWrite(PluginContext pluginContext)
            Logger.Message(TraceLevel.Info, "Done!");

Next, you just need to create an application config file for the Solution Packager tool which references the plugin. The plugin is dynamically loaded and the four methods are called at the appropriate times.

<?xml version="1.0" encoding="utf-8" ?>
    <section name="ComponentConfigurations" type="Microsoft.Crm.Tools.SolutionPackager.ComponentConfigurationSection, SolutionPackager" />
      <add name="CustomControls" type="SolutionPackager.Plugins.Sample, SolutionPackager.Plugins" />

If you run the Solution Packager with this plugin, you will see it log "Done!" to the console at the end. Who knew it was possible to create plugins for the Solution Packager!?! I sure didn't until a few days ago...


No comments.