From 419a9d4a38cdb63c049780c19c5c492c37fc154e Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Wed, 18 Apr 2018 11:44:26 -0500 Subject: [PATCH] Report better version for VS preview consoles For prereleases, the Visual Studio command prompt sets the environment variable `VSCMD_VER` to a value like `15.7.0-pre.3.0`, which is not parseable by System.Version. This could be handled by using a version parser that can handle this SemVer 2 version as well as Windows 4-part versions, but that would be another dependency, so I just special-cased the problematic dash. --- .../Discovery/Providers/DevConsoleInstanceProvider.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/OmniSharp.Host/MSBuild/Discovery/Providers/DevConsoleInstanceProvider.cs b/src/OmniSharp.Host/MSBuild/Discovery/Providers/DevConsoleInstanceProvider.cs index a8c4398787..9e5d218e1f 100644 --- a/src/OmniSharp.Host/MSBuild/Discovery/Providers/DevConsoleInstanceProvider.cs +++ b/src/OmniSharp.Host/MSBuild/Discovery/Providers/DevConsoleInstanceProvider.cs @@ -36,6 +36,17 @@ public override ImmutableArray GetInstances() var versionString = Environment.GetEnvironmentVariable("VSCMD_VER"); Version.TryParse(versionString, out var version); + if (version == null) + { + var dashIndex = versionString.IndexOf('-'); + + if (dashIndex > 0) + { + versionString = versionString.Substring(0, dashIndex); + Version.TryParse(versionString, out version); + } + } + if (version == null) { versionString = Environment.GetEnvironmentVariable("VisualStudioVersion");