How to deploy and register a VSPackage supporting

2020-06-06 06:18发布

问题:

I have an open source VSPackage that I would like to release with support for Visual Studio 2005, Visual Studio 2008, and Visual Studio 2010. I'm trying to figure out how to create the installer and how to perform the package registration with each edition of Visual Studio.

The deployment research I've done indicates my best bet for an installer is a VSIX inside an MSI.

The registration research I've done is a lot less clear. VSPackage registration seems to differ for every edition (VS2005 uses regpkg, VS2008 uses pkgdef, VS2010 uses VSIX).

Can anyone share their experiences and/or point me towards any information about the best approach for targeting multiple versions of Visual Studio? I'm looking for the easiest implementation and preferably keeping it in a single installer if reasonably feasible.

Any help would be greatly appreciated!

回答1:

Short Answer: If you want a single installer that targets/registers with 2005, 2008, & 2010, the choice is quite simple actually. You should create a MSI-based installer and register to HKLM\Software\Microsoft\VisualStudio\(8.0|9.0|10.0).

Explanation: For the MSI/VSIX question...remember that VSIX is new for 2010. A machine with VS 2005/2008 won't know what to do with a VSIX file.

A side note on VSIX....you shouldn't ever put a VSIX file (i.e. the zip container) inside a MSI. If you want a MSI-based extension that also appears in the Extension Manager dialog, you should include a <InstalledByMSI> tag in your extension.vsixmanifest file, and lay down the files already expanded under <VisualStudio2010InstallDir>\Common7\IDE\Extensions\<YourExtensionDirectory>.

As far as registration goes...you have a few things incorrect in your question. For both 2005 and 2008, installers that register packages with Visual Studio should always register under HKEY_LOCAL_MACHINE. (PKgdef in 2008 was only for "Isolated Shell" based applications.) Laying down a pkgdef file is now a supported option in addition to the registry in Visual Studio 2010.

RegPkg is a utility included in the Visual Studio SDK for 2005/2008/2010 that reflects over your package assembly and outputs the appropriate registration information in several different formats. It's meant to be used at development/build time to generate your registration information and shouldn't be used as part of an installer.

CreatePkgDef.exe is a tool in 2010 that is essentially the same as RegPkg.exe, but it only outputs pkgdef files.