--
一、准备工作(在有网的机器上)
1. 下载引导程序
从微软官网下载 vs_Community.exe(社区版)或对应版本。
2. 创建离线布局包
以管理员身份运行 CMD,执行以下命令(确保 D 盘有 40GB 以上可用空间):
cmd
vs_Community.exe --layout "D:\visual_studio_2026_offline" --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Microsoft.VisualStudio.Workload.Data --add Microsoft.VisualStudio.Component.Git --add Microsoft.VisualStudio.Component.ClassDesigner --add Microsoft.VisualStudio.Component.VisualStudioData --add Microsoft.NetCore.Component.SDK --add Microsoft.Net.Component.4.8.SDK --add Microsoft.NetCore.Component.Runtime.6.0 --add Microsoft.NetCore.Component.Runtime.8.0 --includeRecommended --lang zh-CN --useLatestInstaller
下载时间较长,取决于网速,通常需要 1~3 小时。
3. 下载新版代码签名证书(关键步骤)
VS 2026 的安装包使用了 2024 年新版代码签名证书,离线机器上默认没有此证书,必须提前下载。
在有网的机器上,管理员 PowerShell 执行:
powershell
Invoke-WebRequest -Uri "http://www.microsoft.com/pkiops/certs/Microsoft%20Windows%20Code%20Signing%20PCA%202024.crt" -OutFile "D:\CodeSignPCA2024.crt"
注意:使用
http而非https
二、传输文件到目标机器
将以下内容复制到 U 盘或移动硬盘,带到目标机器:
D:\visual_studio_2026_offline\(整个文件夹)D:\CodeSignPCA2024.crt(新版代码签名证书)
三、在目标机器上安装(完全无网环境)
第一步:安装证书(必须最先执行)
以管理员身份运行 CMD,依次执行:
cmd
:: 安装新版代码签名中间证书(最关键)
certutil.exe -addstore -f "CA" "D:\CodeSignPCA2024.crt"
:: 安装离线包自带的根证书
certutil.exe -addstore -f "Root" "D:\visual_studio_2026_offline\certificates\manifestRootCertificate.cer"
certutil.exe -addstore -f "Root" "D:\visual_studio_2026_offline\certificates\manifestCounterSignRootCertificate.cer"
certutil.exe -addstore -f "Root" "D:\visual_studio_2026_offline\certificates\vs_installer_opc.RootCertificate.cer"
每条命令执行后应看到:CertUtil: -addstore 命令成功完成
第二步:首次运行引导程序(安装 VS Installer)
cmd
vs_Community.exe --noweb --layoutPath "D:\visual_studio_2026_offline" --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Microsoft.VisualStudio.Workload.Data --add Microsoft.VisualStudio.Component.Git --add Microsoft.VisualStudio.Component.ClassDesigner --add Microsoft.VisualStudio.Component.VisualStudioData --add Microsoft.NetCore.Component.SDK --add Microsoft.Net.Component.4.8.SDK --add Microsoft.NetCore.Component.Runtime.6.0 --add Microsoft.NetCore.Component.Runtime.8.0 --includeRecommended --locale zh-CN
此步骤会将 VS Installer 安装到
C:\Program Files (x86)\Microsoft Visual Studio\Installer\
第三步:使用 setup.exe 正式安装 VS
cmd
"C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe" install --layoutPath "D:\visual_studio_2026_offline" --noWeb --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Microsoft.VisualStudio.Workload.Data --add Microsoft.VisualStudio.Component.Git --add Microsoft.VisualStudio.Component.ClassDesigner --add Microsoft.VisualStudio.Component.VisualStudioData --add Microsoft.NetCore.Component.SDK --add Microsoft.Net.Component.4.8.SDK --add Microsoft.NetCore.Component.Runtime.6.0 --add Microsoft.NetCore.Component.Runtime.8.0 --includeRecommended --locale zh-CN --in "D:\visual_studio_2026_offline\Response.json"
--in Response.json会自动读取 productId 和 channelId,无需手动填写
四、常见错误排查
查看日志
安装失败时,日志文件位于:
%TEMP%\dd_bootstrapper_*.log
%TEMP%\dd_installer_*.log
%TEMP%\dd_vs_Community_decompression_log.txt
错误一:证书验证失败(最常见)
错误信息:
Certificate is invalid: D:\visual_studio_2026_offline\vs_installer.opc
Error 0x80131509: Signature verification failed
原因: 目标机器缺少 Microsoft Windows Code Signing PCA 2024 中间证书。
解决: 按照第三节第一步,安装所有证书,然后重试。
验证证书是否正确: 用 PowerShell 查看 vs_installer.opc 的签名信息:
powershell
Copy-Item "D:\visual_studio_2026_offline\vs_installer.opc" "D:\vs_installer_opc.zip"
Expand-Archive "D:\vs_installer_opc.zip" -DestinationPath "D:\vs_installer_opc_extracted" -Force
解压后找到签名 XML,查看 Issuer 字段确认证书颁发机构。
错误二:选项"lang"未知
错误信息:
你的参数包含多个错误。第一个错误: 选项"lang"未知
原因: 新版安装程序不支持 --lang 参数。
解决: 将 --lang zh-CN 改为 --locale zh-CN
错误三:layoutPath 多次定义
错误信息:
多次定义了选项"layoutPath"
原因: 直接运行 vs_Community.exe 时,bootstrapper 内部会自动追加一次 --layoutPath,导致重复。
解决: 改为直接调用 setup.exe(见第三节第三步),而不是 vs_Community.exe。
错误四:productId / channelId 不知道填什么
解决: 查看离线包中的 Response.json:
cmd
type "D:\visual_studio_2026_offline\Response.json"
VS 2026 社区版的正确值为:
productId:Microsoft.VisualStudio.Product.CommunitychannelId:VisualStudio.18.Release
或者直接使用 --in Response.json 参数让安装程序自动读取,无需手动填写。
五、组件说明
| 组件 ID | 说明 |
|---|---|
Microsoft.VisualStudio.Workload.ManagedDesktop |
.NET 桌面开发 |
Microsoft.VisualStudio.Workload.NetWeb |
ASP.NET 和 Web 开发 |
Microsoft.VisualStudio.Workload.Data |
数据存储和处理 |
Microsoft.VisualStudio.Component.Git |
Git 版本控制 |
Microsoft.VisualStudio.Component.ClassDesigner |
类设计器 |
Microsoft.VisualStudio.Component.VisualStudioData |
数据源和服务引用 |
Microsoft.NetCore.Component.SDK |
.NET SDK 核心工具链 |
Microsoft.Net.Component.4.8.SDK |
.NET Framework 4.8 SDK |
Microsoft.NetCore.Component.Runtime.6.0 |
.NET 6 运行时 |
Microsoft.NetCore.Component.Runtime.8.0 |
.NET 8 运行时 |
六、系统要求
| 项目 | 要求 |
|---|---|
| 操作系统 | Windows 10 1703 以上 / Windows 11 |
| 磁盘空间 | 布局包约 40GB,安装后约 20~30GB |
| 内存 | 至少 4GB(推荐 8GB) |
| 权限 | 必须以管理员身份运行所有命令 |
七、注意事项
- 所有 CMD / PowerShell 命令必须以管理员身份运行
- 命令中不要出现 Markdown 格式(如
[文字](链接)),直接写组件 ID --skipCertificateCheck参数无法 绕过.opc包的核心签名验证,不要依赖此参数- 离线包内的
certificates文件夹中的证书仅包含旧版根证书,VS 2026 还额外需要 2024 年新版中间证书