gpt4 book ai didi

windows - 如何在无人值守的情况下安装 Visual Studio Build Tools?

转载 作者:行者123 更新时间:2023-12-05 05:36:09 27 4
gpt4 key购买 nike

我正在尝试在 PowerShell 中无人值守地安装 Visual Studio Build Tools。我关注了https://silentinstallhq.com/visual-studio-build-tools-2022-silent-install-how-to-guide/并想出了这个脚本:

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

但是它在 layout... 上停留了几个小时。我的猜测是它要么在请求许可,要么打开了一些对话框。有没有办法打印正在发生的事情?

最佳答案

# 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')

关于windows - 如何在无人值守的情况下安装 Visual Studio Build Tools?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73341154/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com