Skip to content

Commit 6b271bf

Browse files
5an7yCopilot
andcommitted
fix: detect WDK component in both full VS and Build Tools
Full VS editions register the WDK as 'Microsoft.Windows.DriverKit', while Build Tools uses 'Component.Microsoft.Windows.DriverKit.BuildTools'. Query vswhere for both component IDs and deduplicate by install path so machines with only VS Build Tools are properly detected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 05135c4 commit 6b271bf

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

BuildEnvironment.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,21 @@ function Get-VsInstallationsWithWdk {
1818
exit 1
1919
}
2020

21-
$json = & $vswhere -all -products * -format json -requires Microsoft.Windows.DriverKit -include packages 2>$null
22-
$installations = $json | ConvertFrom-Json
21+
# Full VS editions install the WDK component as 'Microsoft.Windows.DriverKit',
22+
# while Build Tools uses 'Component.Microsoft.Windows.DriverKit.BuildTools'.
23+
# Query for either so both product types are discovered.
24+
$wdkComponentIds = @('Microsoft.Windows.DriverKit', 'Component.Microsoft.Windows.DriverKit.BuildTools')
25+
$allInstallations = @()
26+
foreach ($componentId in $wdkComponentIds) {
27+
$json = & $vswhere -all -products * -format json -requires $componentId -include packages 2>$null
28+
if ($json) {
29+
$allInstallations += ($json | ConvertFrom-Json)
30+
}
31+
}
32+
# Deduplicate by installationPath in case both components are present
33+
$installations = $allInstallations | Sort-Object -Property installationPath -Unique
2334
return $installations | ForEach-Object {
24-
$wdkPackage = $_.packages | Where-Object { $_.id -eq 'Microsoft.Windows.DriverKit' } | Select-Object -First 1
35+
$wdkPackage = $_.packages | Where-Object { $_.id -in $wdkComponentIds } | Select-Object -First 1
2536
[PSCustomObject]@{
2637
DisplayName = $_.displayName
2738
InstallationPath = $_.installationPath

0 commit comments

Comments
 (0)