Merge pull request #1531 from Mixaill/windowssdk-registry

scripts/getWindowsSDK: use registry for SDK detection
This commit is contained in:
Robert Schumacher 2017-07-28 17:06:00 -07:00 committed by GitHub
commit 8b6747d01b

View File

@ -17,19 +17,14 @@ $scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition
$validInstances = New-Object System.Collections.ArrayList $validInstances = New-Object System.Collections.ArrayList
$CandidateProgramFiles = $(& $scriptsDir\getProgramFiles32bit.ps1), $(& $scriptsDir\getProgramFilesPlatformBitness.ps1)
Write-Verbose "Program Files Candidate locations: $([system.String]::Join(',', $CandidateProgramFiles))"
# Windows 10 SDK # Windows 10 SDK
Write-Verbose "`n" function CheckWindows10SDK($path)
Write-Verbose "Looking for Windows 10 SDK"
foreach ($ProgramFiles in $CandidateProgramFiles)
{ {
$folder = "$ProgramFiles\Windows Kits\10\Include" $folder = "$path\Include"
if (!(Test-Path $folder)) if (!(Test-Path $folder))
{ {
Write-Verbose "$folder - Not Found" Write-Verbose "$folder - Not Found"
continue return
} }
Write-Verbose "$folder - Found" Write-Verbose "$folder - Found"
@ -42,7 +37,7 @@ foreach ($ProgramFiles in $CandidateProgramFiles)
if (!(Test-Path $windowsheader)) if (!(Test-Path $windowsheader))
{ {
Write-Verbose "$windowsheader - Not Found" Write-Verbose "$windowsheader - Not Found"
continue return
} }
Write-Verbose "$windowsheader - Found" Write-Verbose "$windowsheader - Found"
@ -50,7 +45,7 @@ foreach ($ProgramFiles in $CandidateProgramFiles)
if (!(Test-Path $ddkheader)) if (!(Test-Path $ddkheader))
{ {
Write-Verbose "$ddkheader - Not Found" Write-Verbose "$ddkheader - Not Found"
continue return
} }
Write-Verbose "$ddkheader - Found" Write-Verbose "$ddkheader - Found"
@ -60,16 +55,21 @@ foreach ($ProgramFiles in $CandidateProgramFiles)
} }
} }
# Windows 8.1 SDK
Write-Verbose "`n" Write-Verbose "`n"
Write-Verbose "Looking for Windows 8.1 SDK" Write-Verbose "Looking for Windows 10 SDK"
foreach ($ProgramFiles in $CandidateProgramFiles) CheckWindows10SDK((Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue).KitsRoot10)
CheckWindows10SDK((Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue).KitsRoot10)
CheckWindows10SDK("$env:ProgramFiles\Windows Kits\10")
CheckWindows10SDK("${env:ProgramFiles(x86)}\Windows Kits\10")
# Windows 8.1 SDK
function CheckWindows81SDK($path)
{ {
$folder = "$ProgramFiles\Windows Kits\8.1\Include" $folder = "$path\Include"
if (!(Test-Path $folder)) if (!(Test-Path $folder))
{ {
Write-Verbose "$folder - Not Found" Write-Verbose "$folder - Not Found"
continue return
} }
Write-Verbose "$folder - Found" Write-Verbose "$folder - Found"
@ -78,6 +78,13 @@ foreach ($ProgramFiles in $CandidateProgramFiles)
$validInstances.Add($win81sdkVersionString) > $null $validInstances.Add($win81sdkVersionString) > $null
} }
Write-Verbose "`n"
Write-Verbose "Looking for Windows 8.1 SDK"
CheckWindows81SDK((Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue).KitsRoot81)
CheckWindows81SDK((Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue).KitsRoot81)
CheckWindows81SDK("$env:ProgramFiles\Windows Kits\8.1")
CheckWindows81SDK("${env:ProgramFiles(x86)}\Windows Kits\8.1")
Write-Verbose "`n`n`n" Write-Verbose "`n`n`n"
Write-Verbose "The following Windows SDKs were found:" Write-Verbose "The following Windows SDKs were found:"
foreach ($instance in $validInstances) foreach ($instance in $validInstances)