Extension Manager in Visual Studio 2010
Extensions provide additional functions or customization for a core application. They are popular in many applications, including modern web browsers Internet Explorer and Firefox, Microsoft Office, Media Players, Photoshop, Eclipse, Visual Studio and etc. While some are mere novelties, those for development tools like Eclipse and Visual Studio offer developers significant productivity boosts.
Earlier versions of Visual Studio were built on top of COM technology. Add-ins, Visual Studios primary extensibility option, was implemented via COM interfaces. Over time the add-in mechanism has improved. In 2002 interoperability between the .NET and COM was introduced along with Visual Studio .NET. In Visual Studio 2005, add-in supports a simplified deployment using XML. Later Microsoft announced the Visual Studio SDK packages, a newer mechanism that provides deeper Visual Studio IDE integration through lower level API.
The Visual Studio extensions deployment technologies also improved over the time. Introduced in Visual Studio 2005, the Visual Studio Content Installer (VSI) is used for macros, add-ins, toolbox controls, code snippets, and templates. The Windows Installer Package (MSI) which was used extensively for applications became the main deployment technology for Visual Studio Packages. Both VSI and MSI format files comprise complete packages for distribution.
This design has led to some delivery issues. To get extensions users are required to search, download and install over the countless Internet sites. Managing the extensions dependencies and updates is not easy or straightforward.
Among many new features added to Visual Studio 2010, the new Extension Manager is added to address the extension deployment issues. It follows a new trend of publishing and deploying third-party extensions made popular by projects such as Firefox and Eclipse.
This article gives an introduction to the Visual Studio 2010's Extension Manager. You will learn how to build a simple extension and deploy it on Visual Studio Gallery.
New User Experience
Application extensions are delivered separately with the core application. They are treated more like standalone applications traditionally. While many areas in the Visual Studio extensibility have improved over time, the delivery mechanism has not been changed a lot. It follows the double-clicking workflow, which is not easy.
- Where to find the extensions?
- How to manage the extension lifecycle, include installing, updating and uninstalling?
In the past, finding the right extensions for Visual Studio involved a lot of research. Developers could search the Internet for extensions, or they could get extension information from magazine articles forum posts or blogs.It was difficult to discover all the available options and was hard to compare similar extensions.
That has changed with the Visual Studio Gallery. The web site is the official and centralized resource for Visual Studio extensions. You can browse and subscribe to RSS feeds of the extensions. You can also read the comments and provide your feedback and ratings to the extensions.
Visual Studio 2010 Extension Manager is integrated with the Visual Studio Gallery. It brings the Visual Studio Gallery into Visual Studio IDE (figure 1). There is no need to use the web browser for searching or to run the setup program. Within Visual Studio 2010, the Extension Manager is opened through Tools | Extension Manager menu. When Extension Manager opens up, it lists the extensions already installed. If updates for extensions are available, it lists that too. In the left pane, by clicking on the Online Gallery tab, you can browse and search for extensions available in Visual Studio Gallery. When you select an extension, the related description is displayed in the right pane. Clicking on the Download button, Extension Manager immediately starts downloading the selected extension.
Figure 1, Visual Studio 2010 Extension Manager
Sometimes installing an extension requires a Visual Studio restart. It is painless. The IDE returns back to the previous with the most recent solution loaded. It is equally painless to remove the extension. Open the Extension Manager through Tools | Extension Manager menu, select the extension and click the Uninstall button.
Not only has it provided the convenience of searching and installing extensions within Visual Studio IDE. It also has provided the full lifecycle management of the extensions. Extensions can be enabled/disabled, upgraded and uninstalled within Visual Studio IDE as well.
The ability to enable and disable the extensions in the Extension Manager is worth mentioning. As you will read in the next section in this article, creating and uploading extensions to the Visual Studio Gallery is easier than ever before. There is no approval process in place. The upload is accessible instantly. There may be some risks. Some extensions could have quality issues or have conflicts with other extensions. The disable feature is helpful in this case.
The automated extension update notification is also a great feature. Each time an instance of VS 2010 is opened, it automatically checks for updates to installed extensions. When updates are found, it displays notification icon in the tray. Click on the notification and it will launch the Extension Manager to install new updates. This makes sure that you will have the latest extension updates without any hassle of searching for updates manually.
There are quite a few extensions that are must-have for developers. On the Internet, people tell you their favorite extensions. Here is a list of my picks. You are encouraged to try them out. It is easy and you always can disable and uninstall them if you don’t like them.
- Visual Studio Productivity Power Tool,, a set of tools to improve productivity, such as solution navigator, Tab well UI, Searchable Add Reference Dialog, and etc.
- Snippet Designer, an extension that lets you create code snippet in Visual Studio.
- Spell Check, an extension that provides spell check in plain text files, comments, strings and HTML/ASP.
- Tangible T4 Editor, an extension that provides IntelliSense and syntax highlight for T4 templates
- GhostDoc, an extension that generates XML document comments for C#.
- Feature Builder Power Tool, an extension that helps creating extensions.
- PowerGUI, an extension that provides IntelliSense and syntax highlight for PowerShell scripts.
- IronPython IronRuby Console, an extension that interacts with Visual Studio in IronPython/IronRuby.
The experiences of the Extension Manager remind us of the intuitive workflow of downloading software onto iPhone, downloading plug-ins to FireFox, and downloading books from Amazon to Kindle. This probably is the consumer software deployment trend. It is Internet/Cloud based and application integrated deployment. We most likely will see this software deployment even in next version of Windows itself according to the recent leaked “Windows Store for Windows 8” on the Internet.
Today, Visual Studio 2010 Extension Manager and the Visual Studio Gallery are more extension-centric. In the future, it could be more user-centric. I hope that it can remember my picks of the extensions and apply the extensions to all computers I have logged on.
Create Simple ExtensionIn this section, I will create a Hello World Extension step by step.
When trying out the steps, make sure the Visual Studio SDK is downloaded and installed.
Create Visual Studio Package Project
First, create a new project using the Visual Studio Package Project Template under “Other Project Types | Extensibilities” (Figure 2).
Figure 2, Visual Studio Package Project Template
It launches the Visual Studio Package Wizard, which has 7 pages to fill basic information for the Hello World Package. It is a straightforward process. On step 3, I picked the options of “Menu Command” and “Tool Window” to unfold the initial code for a menu item and a tool window (Figure 3).
Figure 3, Create Menu Command and Tool Window.
Examine the Project Structure
Once the project is created, let’s examine what’s in it. There are a few things that are noticeable and worth mentioning.
There is a source.extension.vsixmanifest file. Within this file, the information entered in the new project wizard is populated, as well as Package References and Contents. It has its own editor (Figure 4).
Figure 4, the source.extension.vsixmanifest File in its Editor
On the project’s properties page, there is a new VSIX tab to let Visual Studio create the VSIX file during build and/or deploy the VSIX when debugging the extension (Figure 4.1).
Figure 4.1, VSIX Tab on the Project Properties Page
Before Visual Studio 2010, extensions were deployed as setup packages more or less like standalone applications. They are installed and maintained separately outside Visual Studio using VSI or MSI. Developers often believe that writing Visual Studio extensions is hard or not something for ordinary developers to do. That is true. Furthermore, it was even harder to create setup packages for Visual Studio extensions.
To create setup packages for Visual Studio 2008 extensions, MSDN article “Tutorial: Simple VSPackage Deployment” suggests using xcopy, the setup project or using Windows Installer XML Toolset (WiX). In all cases, developers have to learn MSI, WiX and understand the registry keys to register the extensions.
Using the setup project options, developers have to write custom installer actions to register extensions. Using WiX it is consuming and error prone to edit the XML file manually and maintain the many GUID values. By default, WiX installation gives minimal functions. Developers have to manipulate more XML to provide features, such as defining installation folder and displaying license information.
In Visual Studio 2010, the improvements have been made in extension developing in at least two areas. It is easier to package the extension using VSIX. The VSIX is the unit of deployment for extensions introduced in Visual Studio 2010. A VSIX file is a zip file that uses the Open Packaging Convention. The VSIX can be installed from the local hard drive like VSI and MSI. Visual Studio recognizes the VSIX file extension, extracts and installs the files in it to the right location. It can also be published and upgraded through the Visual Studio Gallery. The Visual Studio 2010 extension project template generates a VSIX when you build the extension project.
In Visual Studio 2010, developers still need to deal with XML files. But developers won't need to edit the raw XML, instead Visual Studio 2010 provides an editor for that. That is the new VSIX manifest file editor (figure 3). All you need to do is specify the same VSIX ID – the unique identifier and a newer version. Then upload it to the gallery, and customers who have the old version can download the update.
VSIX essentially is a simple xcopy deployment. The installation is to copy and unzip the package. The uninstallation is simply to delete the folder. Advanced installation features such as adding assembly to GAC and creating desktop shortcuts are not supported. It does not write registry outside visual studio hive. It does not support custom action. MSDN article titled “Visual Studio Extension Deployment” gives detailed explanations of what VSIX and MSI can and cannot do.
VSIX is mainly designed for Visual Studio Extension deployment and publishing with Visual Studio Gallery.
Build the Project
After building the project, the build output includes the package DLL, the package definition file (pkgdef) and the VSIX file (Figure 5).
The VSIX file is the package’s deployment file that you can send to users to install or upload to the Visual Studio Gallery.
Figure 5, the Build Output
Debug and Run the Extension
On the project’s properties page, the debug settings are set to launch the Visual Studio Experimental Environment (Figure 6).
Figure 6, Project’s Debug Settings
By hitting F5, a new instance of Visual Studio Experimental Environment launches with VSIX deployed. Visual Studio Experimental Environment runs side by side with the Visual Studio development environment. It is a sandbox for developing and testing Visual Studio Packages. The packages deployed in the experimental environment won’t pollute your main development environment. The experimental environment has its own settings, registry hive and extensions. It can be reset to the clean out of box state using the command "Reset the Microsoft Visual Studio 2010 Experimental instance" from your start menu.
The simple extension gives a “Hello World” menu item under Tools menu (Figure 7) and a “Hello World Tool Window” menu under View | Other Windows (Figure 8), which can be used to show the tool window (Figure 9).
Figure 7, the “Hello World” menu item under Tools menu
Figure 8, the “Hello World Tool Window” menu under View | Other Windows
Figure 9, the Tool Window of the Extension.
The package’s main entry point is in the sub class of Microsoft.VisualStudio.Shell.Package. It has several package registration related attributes that will be used during the installation and registration (Figure 10).
Figure 10, The Package Class
The override function named Initialize is where you can put code to interact with Visual Studio when your package is loaded. In our simple package, the “Hello World” and “Hello World Tool Window” menus are created here in the Initialization function (Figure 11).
Figure 11, The Initialize Function.
The menus’ callback functions are MenuItemCallBack and ShowToolWindow. The MenuItemCallBack function will be triggered when “Hello World” menu is clicked. The default code is to display a message box. It is the start point of your package logic. The ShowToolWindow function will be triggered when “Hello World Tool Window” menu is clicked. The default code is a standard way to bring up the tool window.
Tool windows are child windows of the Visual Studio IDE. Like the Toolbox, Solution Explorer, and Properties window, they can be docked, floating, or tabbed in the document frame. They are dynamic (also known as auto-visible). With Visual Studio’s 2010 support of multi-monitor, tools windows can also be ‘tear-off’ and dragged to second monitor. The Visual Studio Package Project Template by default creates a WPF user control for the tool window.
Now we have a Visual Studio Package skeleton that can be built to generate VSIX for distribution, either through file copies or through the Visual Studio Gallery.
Publish to Visual Studio Gallery
To publish the extensions through Visual Studio Gallery, it is just three steps to get your extension published to be accessible for developers all over the world (figure 12).
- Select a type for your Extension
- Upload the VSIX file
- Add additional categories and description.
Visual Studio Gallery can retrieve metadata from VSIX, including the name, ID, version, company, license, and production image. The version number is used by the Extension Manager to manage the extension updates automatically.
Figure 12, the Visual Studio Gallery
When you have a newer version of your extension, all you need to do is to change version number in the VSIX manifest file editor, build a new VSIX file and upload to the Visual Studio Gallery. Immediately, the updates are available for users to download. Visual Studio displays the new update notification to all users in the system tray when they start a new instance of Visual Studio.
Sometimes it is convenient that Visual Studio Gallery does not have approval process in place. Publishing extensions is as easy as tweeting a message. One tip for extension developers is that you should test as much as you can to ensure the quality. You don’t want to upload the extension and start testing, because it will be publicly visible right away. VSIX supports double-click install just like VSI and MSI. If there are bugs, use the Extension Manager to uninstall it, create a new build of the VSIX and double click to install and test. In this development cycle, you don’t need to increase the version number. Remember to upload Visual Studio Gallery only after completing testing.
This brings up another hint. Visual Studio Gallery does not support private distribution. If your extensions should only be used within your company’s developers, you probably should not upload to Visual Studio Gallery. Instead, you should publish the VSIX file within the company. In this case updates of the extension require manual communication to the extension users.
One of the goals of Visual Studio Gallery is to build an ecosystem of Visual Studio extensions. Since its launch a few years ago with Visual Studio 2008, there have been thousands of extensions uploaded. It is more like community sharing site than a commercial marketplace, like the Apple App Store and Windows Phone Marketplace. If developers want to sell their extensions, they have to have another vendor and payout service like the old fashioned shareware publishing. Users cannot pay through the Extension Manager. Bottom line, the Extension Manager and the Visual Studio Gallery offer excellent support for open source and free extension projects.
Visual Studio 2010's Extension Manager and the Visual Studio Gallery have greatly improved user experiences of both extension users and extension developers. Always remember there are thousands of extensions to extend out of box Visual Studio features. And always remember that you can search and manage extension lifecycle inside the Visual Studio. If you have ideas on how to extend the Visual Studio, you are encouraged to try making Visual Studio extensions. The Visual Studio extensions boost development productivity.
Todd Montgomery Dec 19, 2014