I searched far and wide and was unable to find a good quick tutorial on getting a Visual Studio 2010 extension up and running. There are a few things wrong in the verbiage used that can be quite confusing.
Obtaining the VS 2010 Beta 1 SDK
The first order of business is to get the Visual Studio 2010 Beta 1 SDK, which will add the new templates for creating an extension.
After downloading it and trying to install it you may run across an uncaught exception (like I did)
The error lies in the Bootstrapper (setup.exe). Since the VsSDK_sfx.exe is a self-extracting zip archive you can use your favorite unzipping utility to get the contents. (or you can take the hard way and get the files in your temp folder after it’s been unzipped). I prefer to use WinRar, it makes it extremely easy
After this there are only 5 files extracting.
We only care about 2 of them. vssdk.cab and vssdk.msi.
Launch the vssdk.msi . This is the main installer for the SDK. It gives little feedback and will auto close when it’s done installing.
Creating Your First VS2010 Extension Project
Launch Visual Studio 2010. In your New Projects dialog under <Your Language>/Extensibility you should now have “VSIX Project”
This project defines the basic extension for visual studio. Out of this you will be able to build your VSIX file for installation into Visual Studio.
After giving your new project a name you are given a barebones extension.
The Visual Studio Extension Manifest
First we’ll start off with an unfamiliar file, the extension.vsixmanifest file. This defines your extension, from title, to license agreement to pictures. While this file is a fairly simple XML file. The VS Team provided a nice interface for editing it.
While most of the form is pretty self explanatory, there are some specific points to make
- ID: This is your global ID for your extension. After you first publish your extension, it is probably a good idea to not change this.
- Version: this can be viewed as your installer version. It may not necessarily mirror your dll versions.
- Supported VS Editions: This is a big one and is also forward thinking. Here you can select from all the different versions of VS2010, including Express, Integrated and Isolated Shell. It can also be expanded later to include the next version of VS.
For more information on the vsixmanifest file, see the documentation http://msdn.microsoft.com/en-us/library/dd393700(VS.100).aspx
The last two pieces are where things get interesting. There hasn’t been much said about how extensible Extensions are in VS2010.
Under References you can create references to other VS2010 extensions that your extension may depend on. Clicking on the Add Reference button gives you this dialog.
You’re given the options to select an extension you already have installed, add an external VSIX package or manually define one and a URL to download it from. The URL part is the real beauty. When installing your Extension it has the ability to get the latest and greatest of an extension. You can of course limit it as well to certain version numbers to avoid breaking changes. This creates a lean, mean on demand Extension.
The Content editor doesn’t seem to be fully baked. Here you can add extra content into your vsix package and have it registered upon install. One example is a registering a Project Template. I’ve borrowed an example from the Card Game Starter Kit .
You will find one lone code file in your new project. Here is the CS version
/// Empty VSIX Project.
Not much in there. This is where your imagination comes in
Here is where I’ll leave you to fend on your own for now. Navigating the Visual Studio SDK assemblies is another post all in itself. You’ll find all assemblies you need under the Microsoft.VisualStudio namespace in your add references dialog. It is also possible to tie into Team System via the Microsoft.TeamSystem .
For some full source examples of VS 2010 Extensions, check out the Editor Samples on codeplex