You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Visual Studio Build Tools 2022静默安装特定工作流时无结果求助

Visual Studio Build Tools 2022 静默安装无结果问题排查

问题描述

我正在编写脚本,尝试从本地布局静默安装Visual Studio Build Tools 2022,同时安装Desktop development with C++和MSBuild工作流,使用的PowerShell命令如下:

Start-Process `
  -Passthru `
  -FilePath "vs_setup.exe" `
  "--quiet --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended;includeOptional --add Microsoft.VisualStudio.Workload.MSBuildTools;includeRecommended;includeOptional"

命令运行片刻后无任何结果;将--quiet改为--passive时,能看到「准备Visual Studio安装程序」弹窗,且「下载」「安装」进度条正常完成,但随后进程直接停止并返回命令行。

手动通过安装向导安装可正常完成,我已检查%temp%下的以下安装日志文件:

  • dd_bootstrapper_20250601133753.log
  • dd_installer_20250601133815.log
  • dd_setup_20250601133818.log
  • dd_setup_20250601133818_errors.log
  • dd_vs_setup_decompression_log.txt

所有日志均无错误信息,且显示成功完成。请问出现该问题的原因是什么?我是否错误调用了安装程序?

问题原因与解决方法

1. PowerShell 参数传递错误

你的命令核心问题是Start-Process的参数传递方式错误:安装程序的启动参数需要通过-ArgumentList(可简写为-Args)参数来传递,直接把参数跟在-FilePath后面会被PowerShell识别为无效参数,导致安装程序没有正确接收指令,自然没有预期的安装行为。

修正后的正确命令:

Start-Process `
  -Passthru `
  -FilePath "vs_setup.exe" `
  -ArgumentList "--quiet --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended;includeOptional --add Microsoft.VisualStudio.Workload.MSBuildTools;includeRecommended;includeOptional"

2. 本地布局安装建议添加额外参数

既然是从本地布局运行安装,建议加上--no-web参数,强制安装程序仅使用本地文件,避免因后台尝试联网校验导致的异常终止:

Start-Process `
  -Passthru `
  -FilePath "vs_setup.exe" `
  -ArgumentList "--quiet --no-web --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended;includeOptional --add Microsoft.VisualStudio.Workload.MSBuildTools;includeRecommended;includeOptional"

3. 安装完成验证方式

运行修正后的命令后,可通过以下方式确认安装状态:

  • 检查C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools目录是否存在,且包含MSBuild.exe、VC工具链等核心文件
  • 打开PowerShell运行msbuild -version,查看是否能正常返回Build Tools的版本信息

内容的提问来源于stack exchange,提问作者Joshua Schroijen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 00:22:44