2017-02-09 11:34:19 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
param(
|
2017-02-25 08:27:53 +08:00
|
|
|
[Parameter(Mandatory=$False)]
|
|
|
|
[switch]$DisableWin10SDK = $False,
|
2017-02-09 11:34:19 +08:00
|
|
|
|
2017-02-25 08:27:53 +08:00
|
|
|
[Parameter(Mandatory=$False)]
|
|
|
|
[switch]$DisableWin81SDK = $False
|
2017-02-09 11:34:19 +08:00
|
|
|
)
|
|
|
|
|
2017-02-25 08:27:53 +08:00
|
|
|
if ($DisableWin10SDK -and $DisableWin81SDK)
|
|
|
|
{
|
|
|
|
throw "Both Win10SDK and Win81SDK were disabled."
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Verbose "Executing $($MyInvocation.MyCommand.Name)"
|
|
|
|
|
|
|
|
$validInstances = New-Object System.Collections.ArrayList
|
|
|
|
|
2017-02-09 11:34:19 +08:00
|
|
|
# Windows 10 SDK
|
2017-07-25 17:42:59 +08:00
|
|
|
function CheckWindows10SDK($path)
|
2017-02-09 11:34:19 +08:00
|
|
|
{
|
2017-10-17 08:02:59 +08:00
|
|
|
if ($path -eq $null)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-06 10:47:41 +08:00
|
|
|
$folder = (Join-Path $path "Include")
|
2017-02-09 11:34:19 +08:00
|
|
|
if (!(Test-Path $folder))
|
|
|
|
{
|
2017-02-25 08:27:53 +08:00
|
|
|
Write-Verbose "$folder - Not Found"
|
2017-07-25 17:42:59 +08:00
|
|
|
return
|
2017-02-09 11:34:19 +08:00
|
|
|
}
|
|
|
|
|
2017-02-25 08:27:53 +08:00
|
|
|
Write-Verbose "$folder - Found"
|
2017-02-10 07:26:40 +08:00
|
|
|
$win10sdkVersions = @(Get-ChildItem $folder | Where-Object {$_.Name -match "^10"} | Sort-Object)
|
|
|
|
[array]::Reverse($win10sdkVersions) # Newest SDK first
|
2017-02-09 11:34:19 +08:00
|
|
|
|
2017-02-10 07:26:40 +08:00
|
|
|
foreach ($win10sdkV in $win10sdkVersions)
|
2017-02-09 11:34:19 +08:00
|
|
|
{
|
2017-02-25 08:27:53 +08:00
|
|
|
$windowsheader = "$folder\$win10sdkV\um\windows.h"
|
|
|
|
if (!(Test-Path $windowsheader))
|
2017-02-10 07:26:40 +08:00
|
|
|
{
|
2017-02-25 08:27:53 +08:00
|
|
|
Write-Verbose "$windowsheader - Not Found"
|
2017-10-06 10:47:41 +08:00
|
|
|
continue
|
2017-02-10 07:26:40 +08:00
|
|
|
}
|
2017-02-25 08:27:53 +08:00
|
|
|
Write-Verbose "$windowsheader - Found"
|
2017-04-14 09:59:13 +08:00
|
|
|
|
|
|
|
$ddkheader = "$folder\$win10sdkV\shared\sdkddkver.h"
|
|
|
|
if (!(Test-Path $ddkheader))
|
|
|
|
{
|
|
|
|
Write-Verbose "$ddkheader - Not Found"
|
2017-10-06 10:47:41 +08:00
|
|
|
continue
|
2017-04-14 09:59:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Write-Verbose "$ddkheader - Found"
|
2017-02-25 08:27:53 +08:00
|
|
|
$win10sdkVersionString = $win10sdkV.ToString()
|
|
|
|
Write-Verbose "Found $win10sdkVersionString"
|
|
|
|
$validInstances.Add($win10sdkVersionString) > $null
|
2017-02-09 11:34:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-25 08:27:53 +08:00
|
|
|
Write-Verbose "`n"
|
2017-07-25 17:42:59 +08:00
|
|
|
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)
|
2017-07-29 08:05:38 +08:00
|
|
|
CheckWindows10SDK("$env:ProgramFiles\Windows Kits\10")
|
|
|
|
CheckWindows10SDK("${env:ProgramFiles(x86)}\Windows Kits\10")
|
2017-07-25 17:42:59 +08:00
|
|
|
|
|
|
|
# Windows 8.1 SDK
|
|
|
|
function CheckWindows81SDK($path)
|
2017-02-09 11:34:19 +08:00
|
|
|
{
|
2017-10-17 08:02:59 +08:00
|
|
|
if ($path -eq $null)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-25 17:42:59 +08:00
|
|
|
$folder = "$path\Include"
|
2017-02-25 08:27:53 +08:00
|
|
|
if (!(Test-Path $folder))
|
|
|
|
{
|
|
|
|
Write-Verbose "$folder - Not Found"
|
2017-07-25 17:42:59 +08:00
|
|
|
return
|
2017-02-25 08:27:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Write-Verbose "$folder - Found"
|
|
|
|
$win81sdkVersionString = "8.1"
|
|
|
|
Write-Verbose "Found $win81sdkVersionString"
|
|
|
|
$validInstances.Add($win81sdkVersionString) > $null
|
|
|
|
}
|
|
|
|
|
2017-07-25 17:42:59 +08:00
|
|
|
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)
|
2017-07-29 08:05:38 +08:00
|
|
|
CheckWindows81SDK("$env:ProgramFiles\Windows Kits\8.1")
|
|
|
|
CheckWindows81SDK("${env:ProgramFiles(x86)}\Windows Kits\8.1")
|
2017-07-25 17:42:59 +08:00
|
|
|
|
2017-02-25 08:27:53 +08:00
|
|
|
Write-Verbose "`n`n`n"
|
|
|
|
Write-Verbose "The following Windows SDKs were found:"
|
|
|
|
foreach ($instance in $validInstances)
|
|
|
|
{
|
|
|
|
Write-Verbose $instance
|
|
|
|
}
|
|
|
|
|
|
|
|
# Selecting
|
|
|
|
foreach ($instance in $validInstances)
|
|
|
|
{
|
|
|
|
if (!$DisableWin10SDK -and $instance -match "10.")
|
|
|
|
{
|
|
|
|
return $instance
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$DisableWin81SDK -and $instance -match "8.1")
|
2017-02-09 11:34:19 +08:00
|
|
|
{
|
2017-02-25 08:27:53 +08:00
|
|
|
return $instance
|
2017-02-09 11:34:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-06 10:47:41 +08:00
|
|
|
throw "Could not detect a Windows SDK / TargetPlatformVersion"
|