Simplify extension development with PackageReference and the VSSDK meta package

Mads Kristensen

Visual Studio 2017 version 15.8 made it possible to use the PackageReference syntax to reference NuGet packages in Visual Studio Extensibility (VSIX) projects. This makes it much simpler to reason about NuGet packages and opens the door for having a complete meta package containing the entire VSSDK.

Before using PackageReference, here’s what the References node looked like in a typical VSIX project:

It contained a lot of references to Microsoft.VisualStudio.* packages. Those are the ones we call VSSDK packages because they each make up a piece of the entire public API of Visual Studio.

Migrate to PackageReference

First, we must migrate our VSIX project to use PackageReference. That is described in the Migrate from packages.config to PackageReference documentation. It’s quick and easy.

Once that is done it is time to get rid of all VSSDK packages and installing the meta package.

Installing the VSSDK meta package

The meta package is a single NuGet package that does nothing but reference all the NuGet packages that make up the VSSDK. So, it references all relevant Microsoft.VisualStudio.* packages and is versioned to match major and minor version of Visual Studio.

For instance, if your extension targets Visual Studio 2015, then you need version 14.0 of the VSSDK meta package. If your extension targets Visual Studio 2017 version 15.6, then install the 15.6 version of the VSSDK meta package.

Before installing the meta package, make sure to uninstall all the Microsoft.VisualStudio.*, VsLangProj* and EnvDTE* packages, as well as stdole, Newtonsoft.Json, from your project. After that is done, install the Madskristensen.VisualStudio.SDK package matching the minimum version of Visual Studio your extension supports. It supports all the way back to Visual Studio 2015 version 14.0.

After the meta package is installed, the References node looks a lot simpler:

You can read more about the VSSDK meta package on GitHub.

Known limitations

To use PackageReference and the VSSDK meta package, make sure that:

  1. The VSIX project targets .NET Framework 4.6 or higher
  2. You are using Visual Studio 2017 version 15.8 or higher
  3. You include search for pre-release packages since it is in beta

Try it today

The VSSDK meta package is right now a prototype that we hope to make default in Visual Studio 2019. I’m personally dogfooding it in about 10 production extensions, but we need more extensions to use it to ensure it contains the right dependencies for the various versions of Visual Studio. When it has been properly tested and we’re confident that it will work, it will be renamed to Microsoft.VisualStudio.SDK or similar.

So please try it out and let us know how it works for you.


Discussion is closed.

Feedback usabilla icon