离线安装Visual Studio 2022

1.下载 Visual Studio 引导程序

以community版本为例,即下载vs_community.exe文件。

2.创建Layout

比如我需要安装unity3d、python、nodejs的相关的开发,我需要安装以下模块:

Microsoft.VisualStudio.Component.Unity

Microsoft.VisualStudio.Workload.ManagedDesktop

Microsoft.VisualStudio.Workload.Python

Microsoft.VisualStudio.Workload.Node

具体工作负载和组件ID参考下面链接:

Visual Studio Community 工作负载和组件 ID | Microsoft Learn

执行以下命令创建Layout:

bash 复制代码
D:\localVSlayout\vs_community.exe ^
--layout D:\localVSlayout ^
--add Microsoft.VisualStudio.Component.Unity ^
--add Microsoft.VisualStudio.Workload.ManagedDesktop ^
--add Microsoft.VisualStudio.Workload.Python ^
--add Microsoft.VisualStudio.Workload.Node ^
--includeOptional

3.启动Http服务

将 D:\localVSlayout设置为Http服务的根目录。

以python为例启动Http服务。

python 复制代码
cd /d D:\localVSlayout
python -m http.server 8001

4.执行离线安装

设置以下脚本LayoutUri和BootstrapperName参数,然后在powershell中执行以下脚本进行安装即可。

bash 复制代码
#Do the initial installation from the web hosted layout onto the client in an elevated PowerShell script

    #ADMIN CONFIGURATION
    #Enter layout URI here.上边启动的http服务地址
    $LayoutUri = "http://localhost:8001"

    #Enter bootstrapper name which is present in layout.根据自己的版本修改
    $BootstrapperName = "vs_Community.exe"

    #Add any arguments which you intend to send to bootstrapper.
    $Arguments = "--passive --wait"

    #SCRIPT FUNCTIONALITY
    #Forming URI for bootstrapper
    Write-Verbose "LayoutUri: $LayoutUri"
    $BootstrapperUri = "$LayoutUri/$BootstrapperName"
    Write-Verbose "BootstrapperUri: $BootstrapperUri"

    $Arguments += " --layoutUri $LayoutUri"
    Write-Verbose "Arguments: $Arguments"

    #Creating temp folder and download bootstrapper
    $VSLayoutFolderPath = Join-Path -Path $env:TEMP -ChildPath VSLayout
    $BootstrapperFile = Join-Path -Path $VSLayoutFolderPath -ChildPath $BootstrapperName
    Write-Verbose "The bootstrapper path is: $BootstrapperFile"

    if (Test-Path $VSLayoutFolderPath)
    {
    Write-Verbose "The directory exists - $VSLayoutFolderPath"
    if (Test-Path $BootstrapperFile)
    {
    Write-Verbose "Deleting file - $BootstrapperFile"
    Remove-Item $BootstrapperFile
    }
    }
    else
    {
    Write-Verbose "Creating folder - $VSLayoutFolderPath"
    New-Item -ItemType Directory -Path $VSLayoutFolderPath
    }

    Write-Verbose "Downloading bootstrapper from - $BootstrapperUri to $BootstrapperFile"
    Invoke-WebRequest -Uri $BootstrapperUri -OutFile $BootstrapperFile
    
    Write-Verbose "Starting bootstrapper -$BootstrapperFile with arguments $Arguments"
    start-process $BootstrapperFile $Arguments

注意

本文主要参考微软官方文档,文档很详尽,本文只介绍最基础的离线安装,更多功能还是要认真阅读官方文档。

创建基于网络的安装 - Visual Studio (Windows) | Microsoft Learnhttps://learn.microsoft.com/zh-cn/visualstudio/install/create-a-network-installation-of-visual-studio?view=vs-2022#download-the-visual-studio-bootstrapper-to-create-the-layout

Visual Studio Community 工作负载和组件 ID | Microsoft Learnhttps://learn.microsoft.com/zh-cn/visualstudio/install/workload-component-id-vs-community?view=vs-2022

使用响应文件配置安装默认设置 - Visual Studio (Windows) | Microsoft Learnhttps://learn.microsoft.com/zh-cn/visualstudio/install/automated-installation-with-response-file?view=vs-2022

相关推荐
Desirediscipline13 小时前
#define _CRT_SECURE_NO_WARNINGS 1
开发语言·数据结构·c++·算法·c#·github·visual studio
_codemonster18 小时前
JavaWeb开发系列(九)idea配置jdbc
java·ide·intellij-idea
闪电橘子19 小时前
Pycharm运行程序报错 Process finished with exit code -1066598273 (0xC06D007F)
ide·python·pycharm·cuda
Franklin19 小时前
2025-11-28日,天塌了,Pycharm将不开源了!!最后一个开源社区版本2025.2.5
ide·python·pycharm
智慧地球(AI·Earth)19 小时前
在Windows上使用Claude Code并集成到PyCharm IDE的完整指南
ide·人工智能·windows·python·pycharm·claude code
sensen_kiss20 小时前
IDEA等JetBrains产品(包含PyCharm、Rider等)该如何使用学生认证免费使用其全部功能
ide·pycharm·intellij-idea
超级大的菠萝20 小时前
怎么在Pycharm里面添加模块
ide·python·pycharm
我命由我1234520 小时前
C++ EasyX 开发,MessageBox 函数参数问题:“const char *“ 类型的实参与 “LPCWSTR“ 类型的形参不兼容
c语言·开发语言·c++·后端·学习·visualstudio·visual studio
CodeQingqing21 小时前
cubemx + Keil + vscode + Keil Assistant 工作流
ide·vscode·编辑器·keil
Chasing Aurora1 天前
vscode连接 服务器进行 深度学习
linux·ide·vscode·深度学习·研究生·解压缩·连接服务器