Browse Source

Make Windows10SDK detection more robust

- fixes #1145
pull/1148/head
Dan Shechter 7 years ago committed by Dimitar Dobrev
parent
commit
c75d665310
  1. 22
      src/Core/Toolchains/MSVCToolchain.cs

22
src/Core/Toolchains/MSVCToolchain.cs

@ -38,13 +38,13 @@ namespace CppSharp
} }
/// <summary> /// <summary>
/// Describes the major and minor version of something. /// Describes the major and minor version of something.
/// Each version must be at least non negative and smaller than 100 /// Each version must be at least non negative and smaller than 100
/// </summary> /// </summary>
public struct Version public struct Version
{ {
public int Major; public int Major;
public int Minor; public int Minor;
} }
@ -162,7 +162,7 @@ namespace CppSharp
} }
// we don't know what "latest" is on a given machine // we don't know what "latest" is on a given machine
// so start from the latest specified version and loop until a match is found // so start from the latest specified version and loop until a match is found
for (var i = VisualStudioVersion.Latest - 1; i >= VisualStudioVersion.VS2012; i--) for (var i = VisualStudioVersion.Latest - 1; i >= VisualStudioVersion.VS2012; i--)
{ {
vsVersion = FindVSVersion(i); vsVersion = FindVSVersion(i);
@ -348,7 +348,7 @@ namespace CppSharp
/// <summary> /// <summary>
/// Gets MSBuild installation directories. /// Gets MSBuild installation directories.
/// </summary> /// </summary>
/// ///
/// <returns>Success of the operation</returns> /// <returns>Success of the operation</returns>
public static List<ToolchainVersion> GetMSBuildSdks() public static List<ToolchainVersion> GetMSBuildSdks()
{ {
@ -444,7 +444,7 @@ namespace CppSharp
/// <param name="keyPath">The path to the key in the registry.</param> /// <param name="keyPath">The path to the key in the registry.</param>
/// <param name="matchValue">The value to match in the located key, if any.</param> /// <param name="matchValue">The value to match in the located key, if any.</param>
/// <param name="view">The type of registry, 32 or 64, to target.</param> /// <param name="view">The type of registry, 32 or 64, to target.</param>
/// ///
public static List<ToolchainVersion> GetToolchainsFromSystemRegistryValues( public static List<ToolchainVersion> GetToolchainsFromSystemRegistryValues(
string keyPath, string matchValue, RegistryView view) string keyPath, string matchValue, RegistryView view)
{ {
@ -637,11 +637,15 @@ namespace CppSharp
includes.Add(path + @"\VC\Tools\MSVC\" + version + @"\atlmfc\include"); includes.Add(path + @"\VC\Tools\MSVC\" + version + @"\atlmfc\include");
} }
var sdks = from package in packages var sdks = from package in packages
where package.GetId().Contains("Windows10SDK") || package.GetId().Contains("Windows81SDK") || package.GetId().Contains("Win10SDK_10") where package.GetId().Contains("Windows10SDK") ||
package.GetId().Contains("Windows81SDK") ||
package.GetId().Contains("Win10SDK_10")
select package; select package;
var win10sdks = from sdk in sdks var win10sdks = from sdk in sdks
where sdk.GetId().Contains("Windows10SDK") where regexWinSDK10Version.Match(sdk.GetId()).Success
orderby sdk.GetId()
select sdk; select sdk;
var win8sdks = from sdk in sdks var win8sdks = from sdk in sdks
where sdk.GetId().Contains("Windows81SDK") where sdk.GetId().Contains("Windows81SDK")
select sdk; select sdk;
@ -660,7 +664,7 @@ namespace CppSharp
} }
else else
{ {
path = "<invalid>"; throw new Exception("Windows10SDK should not have been detected, something is terribly wrong");
} }
var shared = Path.Combine(path, "shared"); var shared = Path.Combine(path, "shared");
var um = Path.Combine(path, "um"); var um = Path.Combine(path, "um");
@ -703,7 +707,7 @@ namespace CppSharp
} }
/// <summary> /// <summary>
/// Tries to get all vs 2017 instances. /// Tries to get all vs 2017 instances.
/// </summary> /// </summary>
/// <param name="versions">Collection holding available visual studio instances</param> /// <param name="versions">Collection holding available visual studio instances</param>
/// <returns>Success of the operation</returns> /// <returns>Success of the operation</returns>

Loading…
Cancel
Save