Page 12 - MSDN Magazine, August 2017
P. 12

VISUAL STUDIO
Creating Extensions
for Multiple
Visual Studio Versions
Carlos Quintero
The release of a new version of Visual Studio is always a challenge for developers of extensions (packages, add-ins, templates and so forth). For example, Visual Studio 2010 introduced the new Visual Studio Installer for eXtensions (VSIX files); Visual Studio 2012 introduced the light/dark themes; and Visual Studio 2015 removed add-ins (with the Add-In Manager); not to mention that each Visual Studio version provides a new SDK, new extensibility assemblies and new APIs. With Visual Studio 2017, this challenge is even bigger, due to its new modular setup based on workloads and individual components, and to a new version of the manifest for the VSIX deployment mechanism. While some developers (most notably from Microsoft) release a different new extension for each Visual Studio version, most would prefer to release a single updated extension that can target the widest range of Visual Studio versions.
In this article, I’ll show you how to accomplish this. For this purpose, I’ll focus on the most common scenario: a package with a command, created in a managed language (C#, in this case) and deployed as a VSIX file.
The goals to be accomplished are the following:
• To use a single Visual Studio project to create the package. • To use Visual Studio 2017 for development and debugging. • To generate a single package DLL as the result of the build. • To put that single DLL inside a single VSIX file.
• To be able to install that VSIX file on Visual Studio 2017 and
on many past versions (2015, 2013 and so on).
Because two artifacts are needed—a DLL file (which is the package) and a VSIX file (which is the deployment vehicle for the package)—I’ll explain each of these separately: First, how they work at installation
or run time; second, how to develop them.
The VSIX File
As mentioned earlier, Visual Studio 2010 introduced the VSIX deployment mechanism to install Visual Studio extensions, and it’s been the preferred way ever since. A VSIX file has the extension .vsix and can be installed in different ways. If the VSIX file is published on the Visual Studio Marketplace (formerly Visual Studio Gallery) and it’s compatible with the Visual Studio version and edition you’re using, you can install it using the Extensions and Updates dialog. Under the Tools menu, click on Extensions and Updates and then go to Online | Visual Studio Marketplace (see Figure 1).
This article discusses:
• How Visual Studio extensions are created, deployed and installed • How to create a single package for multiple Visual Studio versions • How to deploy a package with a single VSIX file
Technologies discussed:
Visual Studio 2012, 2013, 2015 and 2017, Microsoft .NET Framework, VSIX files
Code download available at:
msdn.com/magazine/0817magcode
8 msdn magazine













































































   10   11   12   13   14