下载bootstrapper
https://learn.microsoft.com/en-us/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2022#step-1---download-the-visual-studio-bootstrapper
首先制作离线缓存,避免安装时缺少组件,缓存时选择全部组件下载缓存(40GB)
--export
vs_enterprise.exe --layout C:\Users\WDAGUtilityAccount\Desktop\vs_install\localVSlayout --lang en-US
接下来打开一个安装好的VS,导出已安装的组件列表配置文件(命名为vsconfig),放到C:\Users\WDAGUtilityAccount\Desktop\vs_install\目录
最后开始安装
cd C:\Users\WDAGUtilityAccount\Desktop\vs_install\localVSlayout
vs_enterprise.exe --noweb --config "C:\Users\WDAGUtilityAccount\Desktop\vs_install\vsconfig" --includeOptional
请注意 --config 地址要写绝对地址
此命令会弹出安装界面,可以二次修改安装组件列表,安装位置等
如果需要静默安装,需要--passive参数
参考
https://learn.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022&preserve-view=true
https://learn.microsoft.com/en-us/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2022
https://learn.microsoft.com/en-us/visualstudio/install/command-line-parameter-examples?view=vs-2022