Skip to content

Commit c75d665

Browse files
damageboyddobrev
authored andcommitted
Make Windows10SDK detection more robust
- fixes #1145
1 parent 02f70d0 commit c75d665

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/Core/Toolchains/MSVCToolchain.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public struct ToolchainVersion
3838
}
3939

4040
/// <summary>
41-
/// Describes the major and minor version of something.
41+
/// Describes the major and minor version of something.
4242
/// Each version must be at least non negative and smaller than 100
4343
/// </summary>
4444
public struct Version
4545
{
4646
public int Major;
47-
47+
4848
public int Minor;
4949
}
5050

@@ -162,7 +162,7 @@ public static VisualStudioVersion FindVSVersion(VisualStudioVersion vsVersion)
162162
}
163163

164164
// we don't know what "latest" is on a given machine
165-
// so start from the latest specified version and loop until a match is found
165+
// so start from the latest specified version and loop until a match is found
166166
for (var i = VisualStudioVersion.Latest - 1; i >= VisualStudioVersion.VS2012; i--)
167167
{
168168
vsVersion = FindVSVersion(i);
@@ -348,7 +348,7 @@ public static List<ToolchainVersion> GetNetFrameworkSdks()
348348
/// <summary>
349349
/// Gets MSBuild installation directories.
350350
/// </summary>
351-
///
351+
///
352352
/// <returns>Success of the operation</returns>
353353
public static List<ToolchainVersion> GetMSBuildSdks()
354354
{
@@ -444,7 +444,7 @@ public static List<ToolchainVersion> GetVisualStudioSdks()
444444
/// <param name="keyPath">The path to the key in the registry.</param>
445445
/// <param name="matchValue">The value to match in the located key, if any.</param>
446446
/// <param name="view">The type of registry, 32 or 64, to target.</param>
447-
///
447+
///
448448
public static List<ToolchainVersion> GetToolchainsFromSystemRegistryValues(
449449
string keyPath, string matchValue, RegistryView view)
450450
{
@@ -637,11 +637,15 @@ orderby package.GetId()
637637
includes.Add(path + @"\VC\Tools\MSVC\" + version + @"\atlmfc\include");
638638
}
639639
var sdks = from package in packages
640-
where package.GetId().Contains("Windows10SDK") || package.GetId().Contains("Windows81SDK") || package.GetId().Contains("Win10SDK_10")
640+
where package.GetId().Contains("Windows10SDK") ||
641+
package.GetId().Contains("Windows81SDK") ||
642+
package.GetId().Contains("Win10SDK_10")
641643
select package;
642644
var win10sdks = from sdk in sdks
643-
where sdk.GetId().Contains("Windows10SDK")
645+
where regexWinSDK10Version.Match(sdk.GetId()).Success
646+
orderby sdk.GetId()
644647
select sdk;
648+
645649
var win8sdks = from sdk in sdks
646650
where sdk.GetId().Contains("Windows81SDK")
647651
select sdk;
@@ -660,7 +664,7 @@ where sdk.GetId().Contains("Windows81SDK")
660664
}
661665
else
662666
{
663-
path = "<invalid>";
667+
throw new Exception("Windows10SDK should not have been detected, something is terribly wrong");
664668
}
665669
var shared = Path.Combine(path, "shared");
666670
var um = Path.Combine(path, "um");
@@ -703,7 +707,7 @@ where sdk.GetId().Contains("Windows81SDK")
703707
}
704708

705709
/// <summary>
706-
/// Tries to get all vs 2017 instances.
710+
/// Tries to get all vs 2017 instances.
707711
/// </summary>
708712
/// <param name="versions">Collection holding available visual studio instances</param>
709713
/// <returns>Success of the operation</returns>

0 commit comments

Comments
 (0)