-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows: Install Win 10 SDK, clearer name, no Node.js setup #144
base: trunk
Are you sure you want to change the base?
Changes from all commits
a066096
ac494f5
cb3e3ff
51b682b
2a3539b
d707ff5
a7e8550
8dfadff
b3cbf3f
abf5498
2d93f61
41262e8
5bb49fb
c84c8ca
2656bfa
4561513
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Stop script execution when a non-terminating error occurs | ||
$ErrorActionPreference = "Stop" | ||
|
||
Write-Host "--- :windows: Installing Windows 10 SDK and Visual Studio Build Tools" | ||
|
||
$windowsSDKVersionFile = ".windows-10-sdk-version" | ||
if (-not (Test-Path $windowsSDKVersionFile)) { | ||
Write-Output "[!] No Windows 10 SDK version file found at $windowsSDKVersionFile." | ||
exit 1 | ||
} | ||
|
||
$windows10SDKVersion = Get-Content $windowsSDKVersionFile | ||
|
||
Write-Host "Will attempt to set up Windows 10 ($windows10SDKVersion) SDK and Visual Studio Build Tools..." | ||
|
||
# Download the Visual Studio Build Tools Bootstrapper | ||
Write-Output "~~~ Downloading Visual Studio Build Tools..." | ||
|
||
$buildToolsPath = ".\vs_buildtools.exe" | ||
|
||
Invoke-WebRequest ` | ||
-Uri https://aka.ms/vs/17/release/vs_buildtools.exe ` | ||
-OutFile $buildToolsPath | ||
|
||
If (-not (Test-Path $buildToolsPath)) { | ||
Write-Output "[!] Failed to download Visual Studio Build Tools" | ||
Exit 1 | ||
} else { | ||
Write-Output "Successfully downloaded Visual Studio Build Toosl at $buildToolsPath." | ||
} | ||
|
||
# Install the Windows SDK and other required components | ||
Write-Output "~~~ Installing Visual Studio Build Tools..." | ||
Start-Process ` | ||
-FilePath $buildToolsPath ` | ||
-ArgumentList "--quiet --wait --add Microsoft.VisualStudio.Component.Windows10SDK.$windows10SDKVersion" ` | ||
-NoNewWindow ` | ||
-Wait | ||
|
||
# Check if the installation was successful in file system | ||
$windowsSDKsRoot = "C:\Program Files (x86)\Windows Kits\10\bin" | ||
$sdkPath = "$windowsSDKsRoot\10.0.$windows10SDKVersion.0\x64" | ||
If (-not (Test-Path $sdkPath)) { | ||
Write-Output "[!] Failed to install Windows 10 SDK: Could not find SDK at $sdkPath." | ||
If (-not (Test-Path $windowsSDKsRoot)) { | ||
Write-Output "[!] Expected $windowsSDKsRoot to exist, but it does not." | ||
} else { | ||
Write-Output " Found:" | ||
Get-ChildItem -Path $windowsSDKsRoot | ForEach-Object { Write-Output " - $windowsSDKsRoot\$_" } | ||
} | ||
Exit 1 | ||
} | ||
Comment on lines
+32
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an easy way to check if In particular, I'm wondering if the |
||
|
||
Write-Output "Visual Studio Build Tools + Windows 10 ($windows10SDKVersion) SDK installation completed. SDK path: $sdkPath." | ||
Write-Output "Windows 10 SDK path: $sdkPath." | ||
|
||
Write-Output "~~~ Cleaning up..." | ||
Remove-Item -Path $buildToolsPath | ||
Write-Output "All cleaned up." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Stop script execution when a non-terminating error occurs | ||
$ErrorActionPreference = "Stop" | ||
|
||
# It seems like calling refreshenv can erase PATH modifications that previous | ||
# steps in an automation script might have made. | ||
# | ||
# See for example the logs in | ||
# https://buildkite.com/automattic/beeper-desktop/builds/2893#01919717-d0d0-441d-a85d-0fe3223467d2/195 | ||
# | ||
# To avoid the issue, we save the PATH pre-refreshenv and then manually add all | ||
# the components that were removed. | ||
|
||
Write-Host "PATH before refreshenv is $env:PATH" | ||
$originalPath = "$env:PATH" | ||
Write-Host "Calling refreshenv..." | ||
refreshenv | ||
$mergedPath = "$env:PATH;$originalPath" -split ";" | Select-Object -Unique -Skip 1 | ||
$env:PATH = ($mergedPath -join ";") | ||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice 👍 |
||
Write-Host "PATH after refreshenv is $env:PATH" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: how does this
Get-Content
handles possible newlines?Especially, if the version file ends with a newline at end of file, is that trimmed?
Or maybe it's not, but that doesn't cause any issues because when you then reference
$windows10SDKVersion
in other commands like--add Microsoft.VisualStudio.Component.Windows10SDK.$windows10SDKVersion
that's when the value is trimmed as usage/substitution site?What if the file contains 2 newlines at end of file? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! We clearly need to add something to strip them:
https://buildkite.com/automattic/ci-toolkit-buildkite-plugin/builds/1007#01951c5c-320d-4346-8d45-3e9bda56ad1e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
-TotalCount 1
parameter ofGet-Content
can help?Though even if that allows to limit only reading the first line of the file, not 100% sure if it'd properly trim the
\n
at the end of that read line, in that case you might need to also useTrim()
orTrimEnd()
.Tentative suggestion (not tested):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spent more time than I care to admit on this but got a bunch of tests for the version parsing
I'll clean up tomorrow #153