Introducing the VSPackage Builder

Visual Studio Blog

Last week we released the first version of a new project template, VSPackage Builder, which enables rapid development of the command UI and tool window infrastructure of VS 2010 extensions. VSPackage Builder requires VS 2010 Pro or above, and can be installed directly from within VS using the Extension Manager, or indirectly from the Visual Studio Gallery. Installation requires that the VS 2010 SDK be already installed.

Key Features

To introduce some of the key features of the VSPackage Builder project template, let’s use the template to create a new extension project that includes a WPF tool window with a toolbar, and command UI support to allow the tool window to be opened from the Tools menu and from a button on the Standard toolbar, and via a shortcut key. Time to complete this will be 5 minutes or less!

1. Start by creating a new project using the VSPackage Builder template, located under Visual C# > Extensibility in the new project dialog – then add a command to the empty extension by dragging an Add Command quick start from the Toolbox onto the design surface. The result should be as shown.

clip_image002[13]

2. Modify the command’s Button Text, Command Flags, Icon, Name, Priority and Shortcut Keys properties by selecting “Button1” on the design surface and making the appropriate edits using the property browser, as shown.

clip_image004

 

3. Change the command placement location by clicking on the Location property of the External Group instance, and choosing an alternate (Tools Menu [Other 2]). Note the long list of standard IDE locations that are available for selection.

 

clip_image006

 

4. Add another placement for the command by dragging a Group from the External UI category in the Toolbox onto the design surface and updating the Location property as shown. Connect this new “external group” to the command using a Connect control from the toolbox.

 

clip_image008

 

5. Now add a WPF-based toolwindow to the extension by dragging a ToolWindow (WPF) from the Toolwindows category in the toolbox onto the Toolwindow “swimlane” of the design surface. Connect the tool window to the command using a Launch connection, as shown. The Launch connection causes the tool window to be opened whenever the command is executed.

 

clip_image010

 

6. Select the tool window instance on the design surface, and set the tool window properties as shown so that it will appear tabbed with the Solution Explorer when first opened.

 

clip_image012

 

7. Now drag a Toolwindow Toolbar, Group and Combo from the toolbox onto the design surface and connect them and update their Name properties as shown. By connecting the tool window toolbar to the tool window, it will automatically be displayed whenever the tool window is visible.

 

clip_image014

 

8. Save the solution, and press Ctrl-F5 to build and run the extension in the experimental instance.

Press Ctrl-Alt-1 to open the tool window (shown). Note that the new command is available on the Standard toolbar and in the Tools menu as expected.

 

clip_image016

More Information

Much more detail and two additional walkthroughs are included in the VSPackage Builder readme. We highly recommend that prospective extension developers at least browse through the readme before embarking on their own VSPackage Builder based projects.

Background

The VS 2010 SDK includes the Visual Studio Package project template that has for several years been the on ramp for developers building VSPackage-based extensions. This template provides a solid extension starting point, however configuration changes such as adding and placing commands, must be handled through code changes in multiple files and involves a fairly steep learning curve. Feedback on this experience led to the definition of the key requirements for the VSPackage Builder project template, which included:

  • Make it easy to change command UI and tool window infrastructure configuration
  • Support rapid prototyping of command UI that can fully exploit the VS command UI features
  • Help developers learn existing VS extension object models
  • Restrict the volume and complexity of any generated code

As implementation alternatives were explored, we quickly determined that the domain-specific language based design surface approach leveraged by Feature Builder Power Tool, could also be effective in helping to meet VSPackage Builder requirements. An exploration project was initiated with our friends at Clarius Consulting doing much of the implementation heavy lifting, and the end result is VSPackage Builder v1.0 which is being made available for developers to try.

Sending Feedback

Your feedback on the general usefulness of the template, feature suggestions for v2, and bug reports is welcomed. Please send feedback directly to vspbfeed@microsoft.com.

James Bartlett, Senior Program Manager Lead, VS IDE Platform Team

0 comments

Discussion is closed.

Feedback usabilla icon