Skip to content

Commit

Permalink
Support Windows 11 (2/n)
Browse files Browse the repository at this point in the history
+ print valid choice of WinSdkVer for Windows 11 SDK
  • Loading branch information
jonahbeckford committed Jun 26, 2024
1 parent 6ac5d54 commit 0814ca0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/windows/Machine/Machine.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -384,16 +384,26 @@ function Get-VisualStudioProperties {
$VcVarsVerChoice = $Matches.VCVersion
}

# Find a compatible Component.Windows10SDK.<version> or Component.Windows11SDK.<version>
# Find a compatible Component.Windows10SDK.<version> or Win11SDK_<version>
$WindowsSdkCandidates = $VisualStudioInstallation.Packages | Where-Object {
$Windows10SdkCompatibleComponents.Contains($_.Id) -or $Windows11SdkCompatibleComponents.Contains($_.Id)
}
# Pick the latest (not the highest priority) compatible version
# Caution: The different component "UniqueId": "Win10SDK_10.0.19041,version=10.0.19041.1"
# implies that -winsdk=10.0.19041.1. However, it is -winsdk=10.0.19041.0.
# Always use the .0 suffix.
($WindowsSdkCandidates | Sort-Object -Property Version -Descending | Select-Object -Property Id -First 1).Id -match "Microsoft[.]VisualStudio[.]Component[.]Windows1[01]SDK[.](?<WinSDKVersion>.*)"
$WindowsSdkChoice = "10.0.$($Matches.WinSDKVersion).0"
$Id = ($WindowsSdkCandidates | Sort-Object -Property Version -Descending | Select-Object -Property Id -First 1).Id
if ($Id -match "Microsoft[.]VisualStudio[.]Component[.]Windows10SDK[.](?<WinSDKVersion>.*)") {
$WindowsSdkChoice = "10.0.$($Matches.WinSDKVersion).0"
} elseif ($Id -match "Win11SDK_10[.](?<WinSDKMinorVersion>.*)[.](?<WinSDKPatchVersion>.*)") {
$WindowsSdkChoice = "10.$($Matches.WinSDKMinorVersion).$($Matches.WinSDKPatchVersion).0"
} else {
Write-Warning "The Windows SDK identifier '$Id' from candidates $WindowsSdkCandidates is not in a recognized format."
# flush for GitLab CI
[Console]::Out.Flush()
[Console]::Error.Flush()
exit 2
}

@{
InstallPath = $VisualStudioInstallation.InstallationPath;
Expand Down

0 comments on commit 0814ca0

Please sign in to comment.