Share via


Dissecting VS 2010 Package Registration

While it’s still possible to register your packages, by manually or programmatically adding the requisite registry keys and values under the HKLM\Software\Microsoft\VisualStudio\10.0 registry hive, it’s no longer the recommended way to register your packages with the integrated (or isolated) shell.

VS2010 now uses pkgdef and vsixmanifest files to integrate custom packages into the shell. For managed packages, the pkgdef file is generated through the GeneratePkgDef target in Microsoft.VsSDK.targets, which runs the CreatePkgDef build task in Microsoft.VsSDK.Build.Tasks.dll. The CreatePkgDef build task will construct the pkgdef file, by reading/executing the various attributes (like PackageRegistration, ProvideMenuResource, etc) applied to the Package object. For native C++ packages, the .pkgdef file is initially created via the project wizard template, and must be edited manually as changes are made to the package.

The pkgdef file is basically just a tokenized .REG file, which the shell merges with the registry. Note, the use of the registry here is now considered an implementation detail, and may change with subsequent releases; hence the above mentioned recommendation not to use the registry directly, to register your packages. Aaron Marten’s blog ‘All Your RegKeys Are Belong To Us’ details some of the specifics.

The .vsixmanifest is typically used to describe the content of a VSIX package, but is also required to notify the shell about your package, and allows for listing the package under the new Extension Manager.

Unlike VS 2008 where packages are loaded directly from the projects build output directory, a VS 2010 package is loaded from a copy made in the users AppData\Local\Microsoft\VisualStudio\10.0 <Exp> \Extensions subdirectory. With a managed package, these files are copied over via the DeployVsixExtensionFiles target defined in Microsoft.VsSDK.targets. From the proj file, you can define the DeployExtension property to turn this on or off. For native C++ projects, these same files are copied via the <Package> VSIX project, which is a C# flavored project type that uses the above mentioned targets and properties the C# and VB based package projects use.

In summary, if you want to manually add a package to run under the experimental shell environment (when launching devenv.exe with ‘/rootsuffix Exp’), you will need to do the following:

  1. Copy your package assembly to a subdirectory under …<user> \AppData\Local\Microsoft\VisualStudio\10.0Exp\Extensions
  2. Create and copy a pkgdef and vsixmanifest to the same directory
  3. Launch devenv with ‘/rootsuffix Exp’ command line switch
  4. Enable the package via the ‘Tools.Extension Manager’