我正在尝试在 PowerShell 中以无人值守的方式安装 Visual Studio Build Tools。我跟着https://silentinstallhq.com/visual-studio-build-tools-2022-silent-install-how-to-guide/ 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')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)