Monday, May 2, 2016

Creating a new SSMS Ecosystem Project Plugin

I recently wanted to create an SSMS plugin so I was happy to run across Red Gate’s SSMS ecosystem project. It comes with the C# code for a sample plugin, which is nice. But I couldn’t find any documentation on how to setup a new plugin from strach. It wasn’t hard to figure out though.

One Time Setup

The first thing you need to do is to install the Red Gate SSMS Ecosystem Framework. This only has to be done once – it doesn’t have to be repeated for every plugin you write.

Each Time Setup

Here are the steps to follow in Visual Studio for every plugin you create:

1) Create a new Class Library

2) Search Nuget for “Redgate SSMS” and install the RedGate.SIPFrameworkShared package.

3) Rename Class1 to something more fitting.

4) At the top of your code add “using RedGate.SIPSharedFramework”.

5) Create a registry entry for your plugin. The location will depend on whether you’re running a 32-bit or 64-bit version of Windows.

32-bit: HKLM\SOFTWARE\Red Gate\SIPFramework\Plugins

64-bit: HKLM\SOFTWARE\Wow6432Node\Red Gate\SIPFramework\Plugins

At this location create a new String Value. Name it the name of your plugin. Then make the value the path to your project’s dll.

6) Modify your class to inherit from ISsmsAddin4

7) Implement the members of this interface. 

    
    public class MyPlugin : ISsmsAddin4
    {
        public string Version { get { return "1.0.0.0"; } }
        public string Description { get { return "Your add-in's description"; } }
        public string Name { get { return "Your add-in's name"; } }
        public string Author { get { return "Plugin Author"; } }
        public string Url { get { return @"https://example.com"; } }

        public void OnShutdown()
        {
            // Your code here
        }

        public void OnLoad(ISsmsExtendedFunctionalityProvider provider)
        {
            // Your code here
        }

        public void OnNodeChanged(ObjectExplorerNodeDescriptorBase node)
        {
            // Your code here 
        }
    }

 

8) Using the code Red Gate’s sample add-in as your guide, you can now begin to create your plugin.

See the Red Gate website for more information on debugging your plugin.