Reputation: 1776
I'm trying to install Visual Studio Build Tools unattended, in PowerShell. I followed https://silentinstallhq.com/visual-studio-build-tools-2022-silent-install-how-to-guide/ and came up with this script:
Write-Host "Installing visual studio build tools..." -ForegroundColor Cyan
$exePath = "$env:TEMP\vs.exe"
Invoke-WebRequest -Uri https://aka.ms/vs/17/release/vs_BuildTools.exe -UseBasicParsing -OutFile $exePath
Write-Host "layout..." -ForegroundColor Cyan
Start-Process $exePath -ArgumentList "--layout .\vs_BuildTools" -Wait
cd vs_BuildTools
Write-Host "actual installation..." -ForegroundColor Cyan
Start-Process vs_setup.exe -ArgumentList "--installPath $env:USERPROFILE\vs_BuildTools2022 --nocache --wait --noUpdateInstaller --noWeb --allWorkloads --includeRecommended --includeOptional --quiet --norestart" -Wait
however it keeps stuck on layout...
for hours. My guesses are that it either is asking for permission or some dialog opens. Is there a way to print what's happening?
Upvotes: 3
Views: 4279
Reputation: 1776
# Visual Studio build tools
Write-Host "Installing visual studio build tools..." -ForegroundColor Cyan
cd $env:USERPROFILE
$exePath = "$env:TEMP\vs.exe"
Invoke-WebRequest -Uri https://aka.ms/vs/17/release/vs_BuildTools.exe -UseBasicParsing -OutFile $exePath
Write-Host "layout..." -ForegroundColor Cyan
Start-Process $exePath -ArgumentList "--layout .\vs_BuildTools --quiet" -Wait
cd vs_BuildTools
Write-Host "actual installation..." -ForegroundColor Cyan
Start-Process vs_setup.exe -ArgumentList "--installPath $env:USERPROFILE\vs_BuildTools2022 --nocache --wait --noUpdateInstaller --noWeb --allWorkloads --includeRecommended --includeOptional --quiet --norestart" -Wait
[Environment]::SetEnvironmentVariable('Path', "$([Environment]::GetEnvironmentVariable('Path', 'Machine'));$env:USERPROFILE\vs_BuildTools2022", 'Machine')
Upvotes: 1
Reputation: 13588
Before trying to automate the installation, I highly recommend to do it manually at least once. You can just copy the above commands into an interactive PowerShell session and you will see what is going on:
It is just taking ages to install!
And I am not talking about minutes here, but about hours. If you do it interactively, you will see a second console which will print all download steps and display the current progress. You just have to wait a long time until it finishes.
If you want to install it on multiple machines, I recommend to download it only once, serve the layout files (basically your offline installer) on premise and install VS from there.
Upvotes: 0