From 90cf4371c3852a69477dd165538edec04b525e25 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 28 Feb 2018 18:44:02 -0800 Subject: [PATCH] [getWindowsSDK.ps1] Fix error when registry key was not found --- scripts/getWindowsSDK.ps1 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/getWindowsSDK.ps1 b/scripts/getWindowsSDK.ps1 index ed2fd11c71..d5e2f59a20 100644 --- a/scripts/getWindowsSDK.ps1 +++ b/scripts/getWindowsSDK.ps1 @@ -7,6 +7,10 @@ param( [switch]$DisableWin81SDK = $False ) +Set-StrictMode -Version Latest +$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition +. "$scriptsDir\VcpkgPowershellUtils.ps1" + if ($DisableWin10SDK -and $DisableWin81SDK) { throw "Both Win10SDK and Win81SDK were disabled." @@ -61,8 +65,10 @@ function CheckWindows10SDK($path) Write-Verbose "`n" Write-Verbose "Looking for Windows 10 SDK" -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) +$regkey10 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue +$regkey10Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot10' -ErrorAction SilentlyContinue +if (vcpkgHasProperty -object $regkey10 "KitsRoot10") { CheckWindows10SDK($regkey10.KitsRoot10) } +if (vcpkgHasProperty -object $regkey10Wow6432 "KitsRoot10") { CheckWindows10SDK($regkey10Wow6432.KitsRoot10) } CheckWindows10SDK("$env:ProgramFiles\Windows Kits\10") CheckWindows10SDK("${env:ProgramFiles(x86)}\Windows Kits\10") @@ -89,8 +95,10 @@ function CheckWindows81SDK($path) 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) +$regkey81 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue +$regkey81Wow6432 = Get-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots\' -Name 'KitsRoot81' -ErrorAction SilentlyContinue +if (vcpkgHasProperty -object $regkey81 "KitsRoot81") { CheckWindows81SDK($regkey81.KitsRoot81) } +if (vcpkgHasProperty -object $regkey81Wow6432 "KitsRoot81") { CheckWindows81SDK($regkey81Wow6432.KitsRoot81) } CheckWindows81SDK("$env:ProgramFiles\Windows Kits\8.1") CheckWindows81SDK("${env:ProgramFiles(x86)}\Windows Kits\8.1")