Skip to content
Permalink
Browse files

[VSPackage] Run VSIX installer only for VS2017+ (fixes #332)

  • Loading branch information
xen2 committed Jan 21, 2019
1 parent 555b4f4 commit 07438702b7761d95351773c5d1ca56c06da61b1f
@@ -17,7 +17,6 @@
<XenkoAssemblyProcessor>false</XenkoAssemblyProcessor>
<XenkoBuildTags>WindowsTools</XenkoBuildTags>
<XenkoSkipAutoPack>true</XenkoSkipAutoPack>
<PackageVersion>3.0.3</PackageVersion>
<VSSDKTargetPlatformRegRootSuffix>Xenko</VSSDKTargetPlatformRegRootSuffix>
</PropertyGroup>
<ItemGroup>
@@ -2,11 +2,13 @@
<package>
<metadata>
<id>Xenko.VisualStudio.Package</id>
<version>3.0.3</version>
<version>3.0.4</version>
<authors>Xenko</authors>
<owners>Xenko</owners>
<licenseUrl>http://xenko.com/license.txt</licenseUrl>
<licenseUrl>https://github.com/xenko3d/xenko/blob/master/LICENSE.md</licenseUrl>
<projectUrl>http://xenko.com/</projectUrl>
<iconUrl>https://raw.githubusercontent.com/xenko3d/media/master/images/mainlogo/nuget/logo.png</iconUrl>
<repository type="git" url="https://github.com/xenko3d/xenko" />
<copyright>&#169; Xenko contributors and Silicon Studio Corp.</copyright>
<description>Visual Studio Integration Plugin for Xenko</description>
<tags>internal</tags>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="b0b8feb1-7b83-43fc-9fc0-70065ddb80a1" Version="3.0.3" Language="en-US" Publisher="Xenko" />
<Identity Id="b0b8feb1-7b83-43fc-9fc0-70065ddb80a1" Version="3.0.4" Language="en-US" Publisher="Xenko" />
<DisplayName>Xenko</DisplayName>
<Description>Xenko VisualStudio Package</Description>
<Icon>Logo.ico</Icon>
@@ -21,36 +21,31 @@ static int Main(string[] args)
}

const string vsixFile = "Xenko.vsix";

// Locate VSIXInstaller.exe
// We now only deal with VS2017+ which has a unified installer. Still getting latest version of VS possible, in case there is some bugfixes or incompatible changes.
var visualStudioVersionByVsixVersion = VisualStudioVersions.AvailableVisualStudioInstances.Where(x => x.HasVsixInstaller && x.VsixInstallerVersion == VSIXInstallerVersion.VS2017AndFutureVersions);
var visualStudioVersion = visualStudioVersionByVsixVersion.OrderByDescending(x => x.Version).FirstOrDefault(x => File.Exists(x.VsixInstallerPath));
if (visualStudioVersion == null)
{
throw new InvalidOperationException($"Could not find a proper installation of Visual Studio 2017 or later");
}

switch (args[0])
{
case "/install":
case "/repair":
{
// Run it once per VSIX installer version (VS2015 and VS2017+ are separate)
foreach (var visualStudioVersionByVsixVersion in VisualStudioVersions.AvailableVisualStudioInstances.Where(x => x.HasVsixInstaller).GroupBy(x => x.VsixInstallerVersion))
{
var visualStudioVersion = visualStudioVersionByVsixVersion.Last();
if (File.Exists(visualStudioVersion.VsixInstallerPath))
{
var exitCode = RunVsixInstaller(visualStudioVersion.VsixInstallerPath, "\"" + vsixFile + "\"");
if (exitCode != 0)
throw new InvalidOperationException($"VSIX Installer didn't run properly: exit code {exitCode}");
}
}
// Install VSIX
var exitCode = RunVsixInstaller(visualStudioVersion.VsixInstallerPath, "\"" + vsixFile + "\"");
if (exitCode != 0)
throw new InvalidOperationException($"VSIX Installer didn't run properly: exit code {exitCode}");
break;
}
case "/uninstall":
{
// Run it once per VSIX installer version (VS2015 and VS2017+ are separate)
foreach (var visualStudioVersionByVsixVersion in VisualStudioVersions.AvailableVisualStudioInstances.Where(x => x.HasVsixInstaller).GroupBy(x => x.VsixInstallerVersion))
{
var visualStudioVersion = visualStudioVersionByVsixVersion.Last();
if (File.Exists(visualStudioVersion.VsixInstallerPath))
{
// Note: we allow uninstall to fail (i.e. VSIX was not installed for that specific VIsual Studio version)
RunVsixInstaller(visualStudioVersion.VsixInstallerPath, "/uninstall:b0b8feb1-7b83-43fc-9fc0-70065ddb80a1");
}
}
// Note: we allow uninstall to fail (i.e. VSIX was not installed for that specific VIsual Studio version)
RunVsixInstaller(visualStudioVersion.VsixInstallerPath, "/uninstall:b0b8feb1-7b83-43fc-9fc0-70065ddb80a1");
break;
}
}

0 comments on commit 0743870

Please sign in to comment.
You can’t perform that action at this time.