Sunday 13 May 2012

SQL Management Studio (SSMS) 2008 R2 Add-Ins v2.0

Following up on my previous post, I have created a new framework for SQL Management Studio SSMS based on MEF (Managed Extensibility Framework).

Introduction

I created my first SQL AddIn as an IronPython Add-in with the idea to explore the IDE environment more easily allowing for interactive add-in development and to add developer features on the fly. It worked really well but I found that under certain circumstances you wanted to write an Add-In that were static and type safe as well as being as performing as native C#. So I created a new framework using MEF (Managed Extensibility Framework). This allows you to override a very simple base class and just “fill in the blanks” to have your very own Add-In. This also allows me to also create run the IronPython Add-In on top of this to allow for fast testing and prototyping and until you figure out what you wanted to do and how it works and then proceed to use native C# and then just drop in your assembly.

On top of the framework I have created 3 Add-Ins (Plug-ins)

The famous IronPython Add-In:

image_thumb1

The Procedure List:

image_thumb2

Scans the active document and displays a GExperts style listing of the objects.

image_thumb5

Sample command:

A very simple add-in showing you how it all works.

image_thumb6

Downloads:

For the installation packages please visit this link:

http://code.google.com/p/andres-development-resource/downloads/list

For the source code please access this page:

http://code.google.com/p/andres-development-resource/source/checkout

This is a mercurial enabled repository so please follow the links provided to download the source code.

Using the SourceCode.

Load the solution

image_thumb8

Build the solution

You may get errors like this:

image_thumb9

This is fine and only because you have not installed the main add-in and haven’t created the plugins yet. This is just a post-build event to copy the python scripts into the install directory.

Also if you are not planning to use or install the IronPython plugin, you may unload the project to prevent this from happening.

Also this assumes that you will install the project under c:\program files (x86). If this is not the case you may modify this by opening the project properties, post build event.

image_thumb21

Now that you know whats going on it is time to install the main MEF Addin.

Locate the project MEFAddinSetup

Build and install it:

image_thumb20

Just run through the default install:

Installation:

image_thumb22

Once installed the program files directory should look something like this:

image_thumb23

Starting up SQL Management Studio 2008 will now look like this:

image_thumb26

Congratulations you now have the MEF AddIn installed successfully.

Now it is time to add some plug-ins.

Plug-ins:

The plugin system of the new MEF extensible addin is a case of simply dropping compatible assemblies in the installation folder.

You will notice that each plugin has a System.ComponentModel.Composition:

image_thumb27

The plugin must also have an export attribute for a command:

[Export(typeof(IAddInCommand))]

And for each controller:

[Export(typeof(IAddInController))]
 

Commands vs Controllers.

By looking at the sample controllers and commands you will see that the implementation of the controller is simply to override a controller and command class.

The controller is slightly more complicated and allows you to respond to all the events from the IDE. Where the command is intended to give you a simple method for adding a command to the command bar and just responding to its execution event. The Python add-in has an example of a Controller implementation and the Procedure List and Sample command has one for a command.

You will notice the plug-ins in the Plugins folder in the solution

image_thumb28

The first plugin is just a sample to show you how a plugin is created. It adds a command to the command bar and just prints a message once executed.

The ProcedureList is another plugin I created previously that I ported to the new framework to display a list of objects in the document once activated, much like GExperts.

Then finally my first flagship plugin the IronPython that has also been ported to the new framework.

Installation:

Simply build the plugins in the plugins folder NOTE: The Python plugin may fail due to reasons above, if so copy the relevant, scripts, Icons files to the installation folder and rebuild

Finally copy the outputs of each plugin to the installation folder:

My installation folder now looks like this:

image_thumb30

Starting SQL Management Studio now you can see the additional plugins installed.

image_thumb33

That’s it for now, look out for awesome future add-ins I have planned.

SQL Management Studio (SSMS) 2008 R2

Sometime ago I created an Add-In for SQL Management Studio based on IronPython. I have received some feedback and found that there were missing dependencies for the project. In any case I have wanted to correct these dependencies and therefore have created the repositories with all the dependencies here:

http://code.google.com/p/ssms-2008-r2-addins/source/checkout

http://code.google.com/p/procedurelist/source/checkout

http://code.google.com/p/acsr-libraries/source/checkout

Please follow these links to find the source code for the previous Add-Ins that will hopefully contain everything that is required.

These are mercurial repositories so follow the instructions on the page on how to download from these repositories.

Stay tuned for the following post on my new Add-In framework for SQL Management Studio…