Skip to content

Commit 4ccd2b8

Browse files
authored
Select latest Windows SDK version in build workflow
Add step to select the latest Windows SDK version for the build process.
1 parent 2278202 commit 4ccd2b8

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,38 @@ jobs:
278278

279279
- name: Setup MSVC
280280
uses: ilammy/msvc-dev-cmd@v1
281+
282+
- name: Select Windows SDK (>= 10.0.20348.0)
283+
shell: pwsh
284+
run: |
285+
$ErrorActionPreference = "Stop"
286+
287+
$kitsRoot = "C:\Program Files (x86)\Windows Kits\10\Lib"
288+
if (-not (Test-Path $kitsRoot)) {
289+
throw "Windows Kits not found at: $kitsRoot"
290+
}
291+
292+
# Find installed SDK versions
293+
$versions = Get-ChildItem -Directory $kitsRoot | Select-Object -ExpandProperty Name
294+
Write-Host "Installed Windows SDK versions:"
295+
$versions | Sort-Object | ForEach-Object { Write-Host " - $_" }
296+
297+
# Pick the newest one
298+
$selected = ($versions | Sort-Object {[version]$_} | Select-Object -Last 1)
299+
if (-not $selected) { throw "Could not determine installed Windows SDK version." }
300+
301+
Write-Host "Selected Windows SDK version: $selected"
302+
303+
# CMake/VS tooling often expects a trailing backslash in WindowsSDKVersion
304+
"WindowsSDKVersion=$selected\" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV
305+
306+
# Also help CMake explicitly
307+
"CMAKE_SYSTEM_VERSION=$selected" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV
308+
309+
# Sanity check: must be >= 10.0.20348.0
310+
if ([version]($selected.TrimEnd("\")) -lt [version]"10.0.20348.0") {
311+
throw "Selected SDK $selected is still < 10.0.20348.0"
312+
}
281313

282314
- name: Install Ninja
283315
shell: pwsh

0 commit comments

Comments
 (0)