Skip to content

Commit 9eb06fe

Browse files
committed
Add logic to handle new lines and non integers to Win 10 SDK
1 parent cf96e84 commit 9eb06fe

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

bin/install_windows_10_sdk.ps1

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,21 @@ if (-not (Test-Path $windowsSDKVersionFile)) {
99
exit 1
1010
}
1111

12-
$windows10SDKVersion = Get-Content $windowsSDKVersionFile
12+
$windows10SDKVersion = Get-Content $windowsSDKVersionFile `
13+
| Where-Object { $_ -match '\S' } # Remove empty lines
14+
15+
if ($windows10SDKVersion.Count -ne 1) {
16+
Write-Output "[!] Invalid version file format."
17+
Write-Output "Expected exactly one non-empty line, got:"
18+
Write-Output ($windows10SDKVersion -join "`n") # The join poperly formats multiple lines
19+
exit 1
20+
}
21+
22+
if ($windows10SDKVersion -notmatch '^\d+$') {
23+
Write-Output "[!] Invalid version format."
24+
Write-Output "Expected an integer, got: '$windows10SDKVersion'"
25+
exit 1
26+
}
1327

1428
Write-Host "Will attempt to set up Windows 10 ($windows10SDKVersion) SDK and Visual Studio Build Tools..."
1529

0 commit comments

Comments
 (0)