Page 13 - MSDN Magazine, August 2017
P. 13

Figure 1 The Extensions and Updates Dialog Window
You can also double-click a VSIX file. When this happens, a Visual Studio Launcher (C:\\\\Program Files (x86)\\\\Common Files\\\\ Microsoft Shared\\\\MSEnv\\\\VSLauncher.exe) associated to the .vsix file extension is executed; this locates the VSIXInstaller.exe utility of the highest installed Visual Studio version (the highest version is required to be able to install to all lower versions). Then, the VSIX Installer shows the dialog in Figure 2 so you can select the compatible Visual Studio versions and editions in which to install the extension.
VSIX files can be installed programmatically, too, using the VSIXInstaller.exe utility with its command-line options, such as the target Visual Studio version (2017, 2015 and so on) and edition (Community, Professional and the like). You can find that utility in the Common7\\\\IDE subfolder of your Visual Studio installation.
In any case, either Visual Studio or the VSIXInstaller.exe utility needs to know which Visual Studio versions and editions the VSIX file supports. That information can be discovered via a manifest file inside the file. The VSIX file is actually a .zip file, so you can rename its .vsix file extension to .zip and then open it to examine its contents (see Figure 3).
As you can see, there are several files inside: The .dll file is the package DLL. The .pkgdef file is used at installation time to add some keys to the Windows Registry that allows Visual Studio to recognize the DLL as a package. The
As you can see, the manifest states in the InstallationTarget XML ele- ment the supported Visual Studio editions. Here, the Microsoft.Visual- Studio.Pro value targets the Profes- sional edition and higher, such as the Premium, Ultimate, Enterprise and any other such editions. Note that it also targets the Community edition, which is basically a Profes- sional edition with some licensing restrictions and without some features. It also states the range of supported Visual Studio versions: 10.0 (2010), 11.0 (2012), 12.0 (2013), 14.0 (2015), 15.0 (2017).
When the VSIX file of a per-user extension is installed (either by Visual Studio or by the VSIX Installer), the files inside are unzipped and copied to a random folder at this location: C:\users\\\\<user>\\\\AppData\\\\Local\\\\Microsoft\\\\ VisualStudio\\\\<version number>\\\\Extensions\\\\<random folder>. The <version number> can have an “Exp” suffix appended for the “Experimental Instance” (explained later), and for Visual Studio 2017 it will also include the “instance id” of the installed Visual Studio. This instance id is randomly generated at Visual Studio install time; it was added to support side-by-side installations of different editions of the same version (2017) of Visual Studio, something that wasn’t possible before. For machine-wide extensions, the subfolder Common7\\\\IDE\\\\Extensions is used. Notice that in any case each
Visual Studio version uses its own folder for its extensions. While it would be nice if all Visual Studio versions supported the same manifest format, unfortunately that’s not the case. Visual Studio 2010 introduced VSIX and the first version of the manifest. Visual Studio 2012 introduced version 2, which is completely different and incompat- ible with version 1. However, Visual Studio 2012, 2013 and 2015—all of which support version 2—can still accept a version 1 manifest, so you can build a VSIX file with a version 1 and target from Visual Studio 2010 to Visual Studio 2015. But Visual Studio 2017 supports neither version 1 nor version 2. Instead, it requires a third version of the manifest. Fortunately, version 3 keeps using the value “2.0.0.0” in the Version attribute of the PackageMan- ifest XML element and it adds only an XML element named <Prerequisites> (and the two new files, catalog.json and manifest.json, into the VSIX file). So, it’s completely backward-compatible with the second version, supported by Visual Studio 2012, 2013 and 2015 (but not by Visual Studio 2010, which only supports version 1). This means that you can’t target Visual Studio 2010-2017 with a single VSIX file. From this point, I’ll give up on Visual Studio 2010 and will continue with a VSIX file that supports Visual Studio 2012, 2013, 2015 and 2017.
[Content_Types].xml file describes the content type for each file exten- sion (.dll, .json and so forth). The cata- log.json and manifest.json files are required by Visual Studio 2017. And the extension.vsixmanifest file describes the name of the extension, version, and more, and which Visual Studio versions and editions it supports.
You can unzip the extension.vsix- manifest file and open it with a text editor to examine its contents, which will look similar to what’s shown in Figure 4.
msdnmagazine.com
Figure 2 The VSIX Installer
August 2017 9






















































































   11   12   13   14   15