@@ -40,52 +40,82 @@ jobs:
4040 - name : Setup MSBuild
4141 uses : microsoft/setup-msbuild@v2
4242
43- - name : Install Windows Driver Kit (WDK) for WDF/UMDF headers
43+ - name : Ensure UMDF headers (wudfwdm.h) are available
4444 shell : pwsh
4545 run : |
4646 $ErrorActionPreference = "Stop"
47- Write-Output "Ensuring Windows Driver Kit is installed (Chocolatey: windowsdriverkit11)..."
48- choco install windowsdriverkit11 -y --no-progress
49- if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
5047
51- - name : Detect Windows Kits version (UMDF headers)
52- shell : pwsh
53- run : |
54- $ErrorActionPreference = "Stop"
55-
56- $kitsRoot = $null
57- try {
58- $kitsRoot = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -Name "KitsRoot10" -ErrorAction Stop).KitsRoot10
59- } catch {
60- $kitsRoot = Join-Path ${env:ProgramFiles(x86)} "Windows Kits\10\"
48+ function Get-KitsRoot10 {
49+ try {
50+ return (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -Name "KitsRoot10" -ErrorAction Stop).KitsRoot10
51+ } catch {
52+ return (Join-Path ${env:ProgramFiles(x86)} "Windows Kits\10\")
53+ }
6154 }
6255
63- if (-not $kitsRoot -or -not (Test-Path $kitsRoot)) {
64- throw "Windows Kits root not found: $kitsRoot"
65- }
56+ function Find-UmdfHeader([string]$kitsRoot) {
57+ $includeRoot = Join-Path $kitsRoot "Include"
58+ if (-not (Test-Path $includeRoot)) { return $null }
59+
60+ $best =
61+ Get-ChildItem -Path $includeRoot -Directory -ErrorAction SilentlyContinue |
62+ Where-Object { Test-Path (Join-Path $_.FullName "wdf\umdf\wudfwdm.h") } |
63+ Sort-Object -Property Name -Descending |
64+ Select-Object -First 1
65+
66+ if (-not $best) { return $null }
6667
67- $includeRoot = Join-Path $kitsRoot "Include"
68- if (-not (Test-Path $includeRoot)) {
69- throw "Windows Kits Include directory not found: $includeRoot"
68+ return [PSCustomObject]@{
69+ WindowsSdkDir = $kitsRoot
70+ WindowsTargetPlatformVersion = $best.Name
71+ HeaderPath = (Join-Path $best.FullName "wdf\umdf\wudfwdm.h")
72+ }
7073 }
7174
72- $candidates =
73- Get-ChildItem -Path $includeRoot -Directory -ErrorAction SilentlyContinue |
74- Where-Object { Test-Path (Join-Path $_.FullName "wdf\umdf\wudfwdm.h") } |
75- Sort-Object -Property Name -Descending
75+ $kitsRoot = Get-KitsRoot10
76+ Write-Output "KitsRoot10: $kitsRoot"
77+
78+ $found = Find-UmdfHeader -kitsRoot $kitsRoot
79+ if (-not $found) {
80+ Write-Output "UMDF header not found; installing SDK + WDK via winget..."
7681
77- $best = $candidates | Select-Object -First 1
78- if (-not $best) {
82+ if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
83+ throw "winget is not available on this runner, and UMDF headers are missing."
84+ }
85+
86+ winget --version
87+
88+ $ids = @(
89+ "Microsoft.WindowsSDK.10.0.26100",
90+ "Microsoft.WindowsWDK.10.0.26100"
91+ )
92+
93+ foreach ($id in $ids) {
94+ Write-Output "Installing $id ..."
95+ winget install --source winget --exact --id $id --accept-package-agreements --accept-source-agreements --silent --disable-interactivity
96+ if ($LASTEXITCODE -ne 0) {
97+ throw "winget install failed for $id (exit code $LASTEXITCODE)"
98+ }
99+ }
100+
101+ $found = Find-UmdfHeader -kitsRoot $kitsRoot
102+ }
103+
104+ if (-not $found) {
105+ $includeRoot = Join-Path $kitsRoot "Include"
106+ Write-Output "Still missing UMDF header. Include root contents:"
107+ if (Test-Path $includeRoot) {
108+ Get-ChildItem -Path $includeRoot -Directory -ErrorAction SilentlyContinue | ForEach-Object { Write-Output ("- " + $_.Name) }
109+ }
79110 throw "Could not find wdf\\umdf\\wudfwdm.h under: $includeRoot"
80111 }
81112
82- $kitVersion = $best.Name
83- $windowsSdkDir = $kitsRoot
113+ Write-Output "Found UMDF header at: $($found.HeaderPath)"
114+ Write-Output "Using WindowsTargetPlatformVersion: $($found.WindowsTargetPlatformVersion)"
115+ Write-Output "Using WindowsSdkDir: $($found.WindowsSdkDir)"
84116
85- Write-Output "Using WindowsTargetPlatformVersion: $kitVersion"
86- Write-Output "Using WindowsSdkDir: $windowsSdkDir"
87- "WINDOWS_TARGET_PLATFORM_VERSION=$kitVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
88- "WINDOWS_SDK_DIR=$windowsSdkDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
117+ "WINDOWS_TARGET_PLATFORM_VERSION=$($found.WindowsTargetPlatformVersion)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
118+ "WINDOWS_SDK_DIR=$($found.WindowsSdkDir)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
89119
90120 - name : Setup .NET
91121 uses : actions/setup-dotnet@v4
0 commit comments