Dotneteers.net
All for .net, .net for all!

DevTools Ecosystem Summit: Deploying Visual Studio 2010 Extensions, Part 2

<Part1

image

[Quan] Istvan is now going to show you how to create an extension and how to publish it to the Visual Studio gallery.

[Istvan] In this demo I will create a simple package with a Nice Tool Window. I have installed Visual Studio SDK on my machine, and now I create this package using a Visual Studio Package. I go to File|New|Project and select the Visual Studio Integration Package template to start a new project.

image

I name my projects to NiceToolWindow and click OK. The VSPackage template launches the Visual Studio Integration Package Wizard with the following Welcome page:

 image

In the first page I declare that I want to create a C# package.

image

The second page collects a few information about my package used for code generation and displaying branding information.

image

I declare that I want to create only a Tool window this time:

image

I specify the name for my tool window and set the ID to be used for the command showing up it.

image

On the last wizard page I clear the checkboxes, because for this demo I do not want any test projects to be generated.

image

As you see, the wizard creates the code in a few seconds. I can immediately build and run it. By pressing Ctrl+F5 a new Visual Studio instance is started. As you see from its title, it is called “Visual Studio Experimental Instance”. This runs exactly the same devenv.exe as our main instance, but uses a separate set of configuration settings. This instance works as a test bed for the package.

Our nice tool can be accessed  by using the View|Other Windows|Nice Tool Window command. It displays the tool window, and as we click on the button it pops up a message indicating that it really works!

image

Now I close the Experimental instance and go back to the source code generated.

When I ran the package, it was deployed for the Experimental Instance with VSIX. The key of the deployment is the source.extension.vsixmanifest file as you see it here in the Solution Explorer.

image

This file contains all the information used to create the deployment package just as Quan mentioned. When I open it, a new designer displays the content of the manifest. This time in Beta2 this design surface does not seem very polished:

image

Instead, I use the code view, as the VSIX file is actually an XML file, and you can recognize the the sections representing the information Quan talked about:

image

The package is identified by its Id and Version, and it has a few set of display attributes. This manifest tells that the extension is supported by the Professional edition of Visual Studio. The VSPackage element in the Content section tells that our extension is a Visual Studio package. The |NiceToolWindow;PkgdefProjectOutput| token provides the information the build process uses to set up the list of artifacts to be included in the deployment kit.

Let’s build our package, and see what is within the .vsix file we get! Because the .vsix file is a zip archive conforming with the Open Packaging Convention, we can rename it to .zip, open it to look what’s inside:

image

We can see that the NiceToolWindow.dll encapsulation our package is there and also we see a file with the name NiceToolWindow.pkgdef. This latter one contains the registry settings required to register our package which is a COM component.

  1. [$RootKey$\InstalledProducts\NiceToolWindowPackage]
  2. @="#110"
  3. "Package"="{6617051f-7e5c-41b6-9f62-8221d1cfc372}"
  4. "PID"="1.0"
  5. "ProductDetails"="#112"
  6. "LogoID"="#400"
  7. [$RootKey$\Packages\{6617051f-7e5c-41b6-9f62-8221d1cfc372}]
  8. @="DiveDeeper.NiceToolWindow.NiceToolWindowPackage, NiceToolWindow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6c8545f2ca1aeabb"
  9. "InprocServer32"="$WinDir$\SYSTEM32\MSCOREE.DLL"
  10. "Class"="DiveDeeper.NiceToolWindow.NiceToolWindowPackage"
  11. "CodeBase"="$PackageFolder$\NiceToolWindow.dll"
  12. [$RootKey$\Menus]
  13. "{6617051f-7e5c-41b6-9f62-8221d1cfc372}"=", Menus.ctmenu, 1"
  14. [$RootKey$\ToolWindows\{65f23b5e-328d-40f0-9963-59916b77368d}]
  15. @="{6617051f-7e5c-41b6-9f62-8221d1cfc372}"
  16. "Name"="DiveDeeper.NiceToolWindow.MyToolWindow"

In the past with VS 2008 the settings in this file were used to create the MSI installation kit, and had to be put into the install kit in order the package could be registered during setup time. There’s no need to do it anymore! The VSIX installer will extract this information form the zip archive and Visual Studio will use it at the next startup to register the package.

Now, we have seen how our nice tool window’s deployment package has been created. We are going to share this component with the community through Visual Studio Gallery. We can access the gallery with the http://www.visualstudiogallery.com URL.

image

The most important button to share our NiceToolWindow is the Upload button just right below the search text box. Before starting the sharing process, I would like to give you a very short guided tour around the gallery.

You can use the departments under Categories to look for a specific type of component. For example, opening the Tools department and then selecting Coding, you get a list of components related to coding tasks.

image

Under categories you can filter the components by Visual Studio versions. Select Visual Studio 2010 to see which coding tools work with VS 2010:

image

You can also filter by cost category. When you click on “Free” you’ll see only free coding components working with VS 2010.

image

Clicking on a components directs you to the details page where you can immediately download and install the component.

image

So, let’s go back to our original idea, and upload the NiceToolWindow package to the gallery. It contains three easy steps that start with clicking on the Upload button. In order to upload components, you must sign in. The first step is selecting the type of extension. In our case it is a tool.

image

The next step is to decide how we want to upload the component:

image

We can select from two options. We could take the first option to allow community members download it directly from the gallery. In this case the component detail page will display a “Download” button. The second option lets us specify a link to redirect members to another page where we can manage the whole download/purchase process. In this case the component detail page will display a “Get now” button.

I have selected the first option, because I want to share a free component, and I also selected the NiceToolWindow.vsix file to upload. When I click the Next button, the .vsix file is uploaded and you can specify a few more attributes to categorize your component, and also can add a rich text description to it.

image

Before going on, you I to accept the contribution agreement…

image

and my component is ready to be published:

image

At this point I can click on the “publish” link to allow gallery visitors to browse and download NiceToolWindow, as you see it is at the top of the list of recently added components.

image

Now, I put the cap of a community member on my hat to show you how easy is to find and download the uploaded component. I open Visual Studio 2010 and start Extension manager. Because I’m looking for a “nice tool” I type “Nice” in the search box.

image

The simple tool we have just uploaded is on the list! When I click on download, install it, it goes into my Installed Extensions tab.

image

After restarting Visual Studio, this “great” tool can be immediately started. If I do not like it, I can click on the Uninstall button to remove it.

I hope you’ve liked it, and I whet your appetite to share extensions!

image

[Quan] Now that you’ve seen how easy it is to build and deploy an extension, we want you to start building and sharing extensions with the whole world!

In case you ship something and need to make changes later on, we provide a simple update model that removes the existing extension and lays down a new one.  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 your update.

image

So, hopefully we’ve sold you on how cool xcopy deployment is.  It’s so simple, a caveman can do it.

However, xcopy does have limitations which I do want to call out.

We don’t write to the registry outside of the VS hive.  To write to the registry, you can use a pkgdef file.  However, that’s limited to the VS Hive.  Writing keys for anything else, including file associations into HK Classes Root is not supported.  Other things not supported are start menu and desktop shortcuts, framework functionality such as creating Native Images or adding files to the Global Assembly Cache.  Lastly, this is xcopy.  Install is copy or unzip.  Uninstall is delete the folder.  We don’t support custom actions.

If you’re installing a database extension and need to configure your back end SQL Server database, use an MSI.

image

If you extension is completely inside the VS world, VSIX works well and is the recommended extension deployment technology for VS 2010.  If you need to install or configure things outside of VS, we still support MSI installs.  The in product experience will show the MSIs that are uploaded to the VS Gallery however acquiring them will take the user to the landing page in IE where they can download and install the MSI.

image

To make sure your extension appears in the list of installed extensions in the Extension Manager, make sure your MSI installs a VSIX manifest and sets the InstalledByMSI element to true.  The payload will also need to be installed to the VSInstallDir\Common7\IDE\Extensions directory.

If you have registry keys under the VS Hive or packages that need to be registered, use a pkgdef file.  Also, there shouldn’t be a need for you to call devenv.exe /setup for VS 2010.

The end user will be able to see your extension installed however, they will still need to go to Windows Add/Remove programs to remove it.

image

We threw a lot at you today.  So, now that you’ve got all this knowledge, go download and install VS 2010 and the SDK, then start building extensions and sharing them on the VS gallery!

And with that final note, we’re done with our deploying VS extensions talk.

Thank you for your time.  I hope we’ve got you excited about the extension manager and how easy it is to share your extensions!

Posted Oct 21 2009, 12:23 AM by inovak
Filed under: ,

Comments

DevTools Ecosystem Summit: Deploying Visual Studio 2010 Extensions, Part 1 - DiveDeeper's blog - Dotneteers.net wrote DevTools Ecosystem Summit: Deploying Visual Studio 2010 Extensions, Part 1 - DiveDeeper&#39;s blog - Dotneteers.net
on Mon, Oct 26 2009 18:24

Pingback from  DevTools Ecosystem Summit: Deploying Visual Studio 2010 Extensions, Part 1 - DiveDeeper's blog - Dotneteers.net