-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track command to install Windows 10 SDK
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
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." |