Skip to content

Commit fe157ea

Browse files
Improve UMDF header detection in CI workflows
Refactored PowerShell logic in build-and-sign-sequential.yml and ci-validation.yml to robustly detect and install UMDF headers (wudfwdm.h). Now attempts installation via winget if headers are missing, improving reliability on runners without preinstalled SDK/WDK.
1 parent e3924ae commit fe157ea

File tree

2 files changed

+124
-63
lines changed

2 files changed

+124
-63
lines changed

.github/workflows/build-and-sign-sequential.yml

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -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

.github/workflows/ci-validation.yml

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,51 +27,82 @@ jobs:
2727
- name: Setup MSBuild
2828
uses: microsoft/setup-msbuild@v2
2929

30-
- name: Install Windows Driver Kit (WDK)
30+
- name: Ensure UMDF headers (wudfwdm.h) are available
3131
shell: pwsh
3232
run: |
3333
$ErrorActionPreference = "Stop"
34-
choco install windowsdriverkit11 -y --no-progress
35-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
3634
37-
- name: Detect Windows Kits version (UMDF headers)
38-
shell: pwsh
39-
run: |
40-
$ErrorActionPreference = "Stop"
41-
42-
$kitsRoot = $null
43-
try {
44-
$kitsRoot = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -Name "KitsRoot10" -ErrorAction Stop).KitsRoot10
45-
} catch {
46-
$kitsRoot = Join-Path ${env:ProgramFiles(x86)} "Windows Kits\10\"
35+
function Get-KitsRoot10 {
36+
try {
37+
return (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -Name "KitsRoot10" -ErrorAction Stop).KitsRoot10
38+
} catch {
39+
return (Join-Path ${env:ProgramFiles(x86)} "Windows Kits\10\")
40+
}
4741
}
4842
49-
if (-not $kitsRoot -or -not (Test-Path $kitsRoot)) {
50-
throw "Windows Kits root not found: $kitsRoot"
51-
}
43+
function Find-UmdfHeader([string]$kitsRoot) {
44+
$includeRoot = Join-Path $kitsRoot "Include"
45+
if (-not (Test-Path $includeRoot)) { return $null }
46+
47+
$best =
48+
Get-ChildItem -Path $includeRoot -Directory -ErrorAction SilentlyContinue |
49+
Where-Object { Test-Path (Join-Path $_.FullName "wdf\umdf\wudfwdm.h") } |
50+
Sort-Object -Property Name -Descending |
51+
Select-Object -First 1
52+
53+
if (-not $best) { return $null }
5254
53-
$includeRoot = Join-Path $kitsRoot "Include"
54-
if (-not (Test-Path $includeRoot)) {
55-
throw "Windows Kits Include directory not found: $includeRoot"
55+
return [PSCustomObject]@{
56+
WindowsSdkDir = $kitsRoot
57+
WindowsTargetPlatformVersion = $best.Name
58+
HeaderPath = (Join-Path $best.FullName "wdf\umdf\wudfwdm.h")
59+
}
5660
}
5761
58-
$candidates =
59-
Get-ChildItem -Path $includeRoot -Directory -ErrorAction SilentlyContinue |
60-
Where-Object { Test-Path (Join-Path $_.FullName "wdf\umdf\wudfwdm.h") } |
61-
Sort-Object -Property Name -Descending
62+
$kitsRoot = Get-KitsRoot10
63+
Write-Output "KitsRoot10: $kitsRoot"
64+
65+
$found = Find-UmdfHeader -kitsRoot $kitsRoot
66+
if (-not $found) {
67+
Write-Output "UMDF header not found; installing SDK + WDK via winget..."
68+
69+
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
70+
throw "winget is not available on this runner, and UMDF headers are missing."
71+
}
72+
73+
winget --version
74+
75+
$ids = @(
76+
"Microsoft.WindowsSDK.10.0.26100",
77+
"Microsoft.WindowsWDK.10.0.26100"
78+
)
79+
80+
foreach ($id in $ids) {
81+
Write-Output "Installing $id ..."
82+
winget install --source winget --exact --id $id --accept-package-agreements --accept-source-agreements --silent --disable-interactivity
83+
if ($LASTEXITCODE -ne 0) {
84+
throw "winget install failed for $id (exit code $LASTEXITCODE)"
85+
}
86+
}
87+
88+
$found = Find-UmdfHeader -kitsRoot $kitsRoot
89+
}
6290
63-
$best = $candidates | Select-Object -First 1
64-
if (-not $best) {
91+
if (-not $found) {
92+
$includeRoot = Join-Path $kitsRoot "Include"
93+
Write-Output "Still missing UMDF header. Include root contents:"
94+
if (Test-Path $includeRoot) {
95+
Get-ChildItem -Path $includeRoot -Directory -ErrorAction SilentlyContinue | ForEach-Object { Write-Output ("- " + $_.Name) }
96+
}
6597
throw "Could not find wdf\\umdf\\wudfwdm.h under: $includeRoot"
6698
}
6799
68-
$kitVersion = $best.Name
69-
$windowsSdkDir = $kitsRoot
100+
Write-Output "Found UMDF header at: $($found.HeaderPath)"
101+
Write-Output "Using WindowsTargetPlatformVersion: $($found.WindowsTargetPlatformVersion)"
102+
Write-Output "Using WindowsSdkDir: $($found.WindowsSdkDir)"
70103
71-
Write-Output "Using WindowsTargetPlatformVersion: $kitVersion"
72-
Write-Output "Using WindowsSdkDir: $windowsSdkDir"
73-
"WINDOWS_TARGET_PLATFORM_VERSION=$kitVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
74-
"WINDOWS_SDK_DIR=$windowsSdkDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
104+
"WINDOWS_TARGET_PLATFORM_VERSION=$($found.WindowsTargetPlatformVersion)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
105+
"WINDOWS_SDK_DIR=$($found.WindowsSdkDir)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
75106
76107
- name: Setup Node.js
77108
uses: actions/setup-node@v4

0 commit comments

Comments
 (0)