Skip to content

Commit

Permalink
Merge branch 'stevencohn:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
weissm authored Oct 9, 2023
2 parents 93bc5d7 + 8588c91 commit 65eaa7b
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions update-sdk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Begin

function GetSDKVersion
{
$script:netpath = [System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()
# use powershell explicitly because pwsh will return wrong path
$script:netpath = (powershell -c '[System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()')

$0 = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots'
if (!(Test-Path $0))
Expand All @@ -69,9 +70,6 @@ Begin
{
$updated = $false

$fullpath = $kitsroot; 'UnionMetadata', $sdkver, 'Windows.winmd' | `
ForEach-Object { $fullpath = Join-Path $fullpath $_ }

$lines = @(Get-Content $csproj)

for ($i =0; $i -lt $lines.Count; $i++)
Expand All @@ -93,24 +91,20 @@ Begin
WriteOK 'NET Framework path is already correct'
}
}
# $matches[1]=sdkpath, $matches[2]==version
# $matches[1]=sdkpath, $matches[2]=version
elseif ($line -match '<HintPath>(.+\\)UnionMetadata\\(\d+\.\d+\.\d+\.\d+)\\Windows.winmd</HintPath>')
{
$p = [System.IO.Path]::GetFullPath($basePath + $matches[1])

if ((!(Test-Path $p)) -or $forceBase)
$p = "$($matches[1])UnionMetadata\\$($matches[2])\\Windows.winmd"
if (($matches[2] -ne $sdkver) -or ![System.IO.Path]::Exists($p))
{
# replace relative path with absolute path
WriteOK "applying full path to Windows SDK: $fullpath"
# always forces base
$fullpath = $kitsroot; 'UnionMetadata', $sdkver, 'Windows.winmd' | `
foreach { $fullpath = Join-Path $fullpath $_ }

WriteOK "patching Windows SDK path: $fullpath"
$lines[$i] = "<HintPath>$fullpath</HintPath>"
$handled = $true
}
elseif ($matches[2] -ne $sdkver)
{
WriteOK "patching Windows SDK version: $sdkver"
$lines[$i] = $line.Replace($matches[2], $sdkver)
$handled = $true
}
else
{
WriteOK 'Windows SDK is already correct'
Expand Down

0 comments on commit 65eaa7b

Please sign in to comment.