更新基于网络的 Visual Studio 安装Update a network-based installation of Visual Studio

可以使用最新的产品更新来更新 Visual Studio 的网络安装布局,以便将它用作 Visual Studio 最新更新的安装点,同时还可用于维护已部署到客户端工作站的安装。It's possible to update a network installation layout of Visual Studio with the latest product updates so that it can be used both as an installation point for the latest update of Visual Studio and also to maintain installations that are already deployed to client workstations.

如何更新网络布局How to update a network layout

重要

这些说明假定你之前已创建了一个网络安装布局。These instructions assume that you've previously created a network installation layout. 要详细了解如何执行此操作,请参阅创建 Visual Studio 的网络安装页面。For more information about how to do so, see the Create a network installation of Visual Studio page.

要刷新网络安装共享,使其包含最新更新,请运行 --layout 命令,从而以增量方式下载更新后的包。To refresh your network install share so that it includes the latest updates, run the --layout command to incrementally download updated packages.

15.3 中的新增功能:如果你在首次创建网络布局时选择了部分布局,这些设置将被保存。New in 15.3: If you selected a partial layout when you first created the network layout, those settings are saved. 此后一切布局命令都将使用先前的选项以及任何指定的新选项。Any future layout commands use the previous options plus any new options that you specify. 但是,如果正在使用早期版本的布局,则应使用与首次创建网络安装布局相同的命令行参数(即相同的工作负载和语言)来更新其内容。But if you are using a layout of an earlier version, you should use the same command-line parameters that you used when you first created the network install layout (in other words, the same workloads and languages) to update its content.

如果你在首次创建网络布局时选择了部分布局,这些设置将被保存。If you selected a partial layout when you first created the network layout, those settings are saved. 此后一切布局命令都将使用先前的选项以及任何指定的新选项。Any future layout commands use the previous options plus any new options that you specify.

如果在文件共享上托管布局,则应更新布局的私有副本(例如 c:\VSLayout),然后下载所有已更新内容,并将其复制到文件共享(例如 \server\products\VS)。If you host a layout on a file share, you should update a private copy of the layout (for example, c:\VSLayout) and then, after all of the updated content is downloaded, copy it to your file share (for example, \server\products\VS). 如果不这样做,那么任何在布局更新时运行安装程序的用户,将更有可能无法通过布局获取所有内容,因为布局并未完全更新。If you don't do this, there is a greater chance that any users who run Setup while you are updating the layout might not be able to get all of the content from the layout because it is not yet completely updated.

请浏览下面几个示例,它们说明如何创建并更新布局:Let's walk through a few examples of how to create and then update a layout:

  • 首先,以下示例说明如何通过一个工作负载来创建布局(仅限英语):First, here's an example of how to create a layout with one workload for English only:

    vs_enterprise.exe --layout c:\VSLayout --add Microsoft.VisualStudio.Workload.ManagedDesktop --lang en-US
    
  • 将相同布局更新到较新版本的说明如下。Here's how to update that same layout to a newer version. 无需指定任何额外的命令行参数。You don't have to specify any additional command-line parameters. 此布局文件夹中的任何后续布局命令都将使用先前所保存的设置。The previous settings were saved and will be used by any subsequent layout commands in this layout folder.

    vs_enterprise.exe --layout c:\VSLayout
    
  • 下面介绍如何以无人参与方式将布局更新为较新版本。Here's how to update your layout to a newer version in an unattended manner. 布局操作在新控制台窗口中运行设置进程。The layout operation runs the setup process in a new console window. 该窗口保持打开状态,以便用户可以看到最终结果以及任何可能发生的错误的摘要。The window is left open so users can see the final result and a summary of any errors that might have occurred. 如果以无人参与方式执行布局操作(例如,具有定期运行以将布局更新为最新版本的脚本),则使用 --passive 参数,进程会自动关闭窗口。If you are performing a layout operation in an unattended manner (for example, you have a script that is regularly run to update your layout to the latest version), then use the --passive parameter and the process will automatically close the window.

    vs_enterprise.exe --layout c:\VSLayout --passive
    
  • 添加额外工作负载和本地化语言的方法如下所示。Here's how to add an additional workload and localized language. (此命令添加 Azure 开发工作负载。)现在,此布局中同时加入了托管桌面和 Azure。(This command adds the Azure development workload.) Now both Managed Desktop and Azure are included in this layout. 这些工作负载中还同时加入了英语和德语的语言资源。The language resources for English and German are also included for all these workloads. 并且已将布局更新至最新的可用版本。And, the layout is updated to the latest available version.

    vs_enterprise.exe --layout c:\VSLayout --add Microsoft.VisualStudio.Workload.Azure --lang de-DE
    

    重要

    更新操作不会安装新添加的可选组件。An update operation doesn't install newly added optional components. 如果需要新添加的可选组件,请在 Layout.JSON 响应文件 中删除旧的可选组件,然后将所需组件包含在 Layout.JSON 的“添加”部分。If you need the newly added optional components, please remove the old optional components in the Layout.JSON response file and include the components you need in the "add" section of Layout.JSON.

    解决方法:升级后运行单独的修改操作以安装缺少的组件。Workaround: Run a separate modify operation after an upgrade to install the missing components.

  • 最后,有关如何在不更新版本的前提下添加其他工作负载和本地化语言的说明详见此处。And finally, here's how to add an additional workload and localized language without updating the version. (此命令添加“ASP.NET 和 Web 开发”工作负载。)当前,托管桌面、Azure 以及 ASP.NET 和 Web 开发工作负载已加入此布局。(This command adds the ASP.NET and web development workload.) Now the Managed Desktop, Azure, and ASP.NET & Web Development workloads are included in this layout. 这些工作负载中还加入了英语、德语和法语的语言资源。The language resources for English, German, and French are also included for all these workloads. 但在运行此命令时,布局不会更新至最新的可用版本。However, the layout was not updated to the latest available version when this command was run. 它将维持现有版本。It remains at the existing version.

    vs_enterprise.exe --layout c:\VSLayout --add Microsoft.VisualStudio.Workload.NetWeb --lang fr-FR --keepLayoutVersion
    

将更新部署到客户端计算机Deploy an update to client machines

更新可以由企业管理员进行部署,也可以由客户端计算机启动,具体视网络环境的配置方式而定。Depending on how your network environment is configured, an update can either be deployed by an enterprise administrator or initiated from a client machine.

  • 用户可以更新通过脱机安装文件夹安装的 Visual Studio 实例:Users can update a Visual Studio instance that was installed from an offline installation folder:
    • 运行 Visual Studio 安装程序。Run the Visual Studio Installer.
    • 然后,单击“更新”。Then, click Update.
  • 管理员可以单独使用下面两个命令,更新 Visual Studio 的客户端部署,而无需与任何用户进行交互:Administrators can update client deployments of Visual Studio without any user interaction with two separate commands:
    • 首先,更新 Visual Studio 安装程序:First, update the Visual Studio installer:
      vs_enterprise.exe --quiet --update
    • 然后,更新 Visual Studio 应用程序本身:Then, update the Visual Studio application itself:
      vs_enterprise.exe update --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise" --quiet --wait --norestart
  • 管理员可以单独使用下面两个命令,更新 Visual Studio 的客户端部署,而无需与任何用户进行交互:Administrators can update client deployments of Visual Studio without any user interaction with two separate commands:
    • 首先,更新 Visual Studio 安装程序:First, update the Visual Studio installer:
      vs_enterprise.exe --quiet --update
    • 然后,更新 Visual Studio 应用程序本身:Then, update the Visual Studio application itself:
      vs_enterprise.exe update --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" --quiet --wait --norestart

备注

使用 vswhere.exe 命令可标识客户端计算机上 Visual Studio 现有实例的安装路径。Use the vswhere.exe command to identify the install path of an existing instance of Visual Studio on a client machine.

提示

若要详细了解如何控制何时向用户显示更新通知,请参阅控制对基于网络的 Visual Studio 部署的更新For details on how to control when update notifications are presented to users, see Control updates to network-based Visual Studio deployments.

验证布局Verify a layout

使用 --verify 在提供的脱机缓存中执行验证。Use --verify to perform verification on the offline cache supplied. 它将检查包文件是否缺少或无效。It checks if packages files are either missing or invalid. 验证完成后,它将打印缺少的文件和无效文件的列表。At the end of the verification, it prints the list of missing files and invalid files.

vs_enterprise.exe --layout <layoutDir> --verify

可在 layoutDir 内调用 vs_enterprise.exe。The vs_enterprise.exe can be invoked inside the layoutDir.

备注

--verify 选项所需的某些重要元数据文件必须位于布局脱机缓存内部。Some important metadata files that are needed by the --verify option must be in the layout offline cache. 如果缺少这些元数据文件,则无法运行“--verify”,且安装程序会出错。If these metadata files are missing, "--verify" cannot run and Setup gives you an error. 如果遇到此错误,请重新创建新脱机布局到其他文件夹(或到相同的脱机缓存文件夹)。If you experience this error, re-create a new offline layout to a different folder (or to the same offline cache folder. 要执行此操作,请运行与创建初始脱机布局相同的布局命令。To so do, run the same layout command that you used to create the initial offline layout. 例如 vs_enterprise.exe --layout <layoutDir>For example, vs_enterprise.exe --layout <layoutDir>.

由于 Microsoft 定期为 Visual Studio 提供更新,因此新创建的布局与初始布局的版本可能不同。Microsoft ships updates to Visual Studio periodically, so the new layout that you create might not be the same version as the initial layout.

备注

验证仅适用于 Visual Studio 的特定次要版本的最新版本。Verification works only for the latest version of a specific minor version of Visual Studio. 发布新版本后,验证将不适用于同一次要版本的早期修补级别版本。As soon as a new version is released, verification won't work for earlier patch level releases of the same minor version.

修复布局Fix a layout

使用 --fix 执行与 --verify 相同的验证,并尝试修复标识的问题。Use --fix to perform the same verification as --verify and also try to fix the identified issues. --fix 过程需要 Internet 连接,因此在调用 --fix 前请确保计算机已连接至 Internet。The --fix process needs an internet connection, so make sure your machine is connected to the internet before you invoke --fix.

vs_enterprise.exe --layout <layoutDir> --fix

可在 layoutDir 内调用 vs_enterprise.exe。The vs_enterprise.exe can be invoked inside the layoutDir.

从布局中删除旧版本Remove older versions from a layout

对脱机缓存执行布局更新后,布局缓存文件夹中可能存在某些已过时的包,最新版本的 Visual Studio 安装不再需要这些包。After you perform layout updates to an offline cache, the layout cache folder may have some obsolete packages that are no longer needed by the latest Visual Studio installation. 可使用 --clean 选项从脱机缓存文件夹中删除已过时的包。You can use the --clean option to remove obsolete packages from an offline cache folder.

要执行此操作,需要前往目录清单的文件路径,其中包含这些已过时的包。To do this, you'll need the file path(s) to catalog manifest(s) that contain those obsolete packages. 可在脱机布局缓存的“存档”文件夹中找到该目录清单。You can find the catalog manifests in an "Archive" folder in the offline layout cache. 更新布局时,这些目录清单就保存在此处。They are saved there when you update a layout. 在“存档”文件夹中,有一个或多个名为“GUID”的文件夹,其中每个都包含已过时的目录清单。In the "Archive" folder, there is one or more "GUID" named folders, each of which contains an obsolete catalog manifest. “GUID”文件夹数目应与脱机缓存的更新次数保持一致。The number of "GUID" folders should be the same as the number of updates made to your offline cache.

每个“GUID”文件夹中都保存着若干文件。A few files are saved inside each "GUID" folder. 最重要的两个文件分别是“catalog.json”文件和“version.txt”文件。The two files of most interest are a "catalog.json" file and a "version.txt" file. “catalog.json”文件需要传递给 --clean 选项的已过时目录清单。The "catalog.json" file is the obsolete catalog manifest you'll need to pass to the --clean option. 另一个 version.txt 文件则包含此已过时目录清单的版本。The other version.txt file contains the version of this obsolete catalog manifest. 根据版本号,可自行决定是否要从此目录清单中删除已过时包。Based on the version number, you can decide whether you want to remove obsolete packages from this catalog manifest. 其他“GUID”文件夹中可执行同样的操作。You can do the same as you go through the other "GUID" folders. 选择要清除的目录后,通过向这些目录提供文件路径来运行 --clean 命令。After you make the decision on the catalog(s) you want to clean, run the --clean command by supplying the files paths to these catalogs.

以下几个示例说明了如何使用 --clean 选项:Here are a few examples of how to use the --clean option:

vs_enterprise.exe --layout <layoutDir> --clean <file-path-of-catalog1> <file-path-of-catalog2> …
vs_enterprise.exe --layout <layoutDir> --clean <file-path-of-catalog1> --clean <file-path-of-catalog2> …

还可在 <layoutDir> 中调用 vs_enterprise.exe。You can also invoke vs_enterprise.exe inside the <layoutDir>. 以下是一个示例:Here's an example:

c:\VSLayout\vs_enterprise.exe --layout c:\VSLayout --clean c:\VSLayout\Archive\1cd70189-fc55-4583-8ad8-a2711e928325\Catalog.json --clean c:\VS2017Layout\Archive\d420889f-6aad-4ba4-99e4-ed7833795a10\Catalog.json

执行此命令时,安装程序会分析脱机缓存文件夹,以查找要删除的文件列表。When you execute this command, Setup analyzes your offline cache folder to find the list of files that it will remove. 然后,可以对要删除的文件进行评审,并确认是否删除。You will then have a chance to review the files that are going to be deleted and confirm the deletions.

获取对脱机安装程序的支持Get support for your offline installer

如果脱机安装遇到问题,请告知我们。If you experience a problem with your offline installation, we want to know about it. 告知我们的最好方式是使用报告问题工具。The best way to tell us is by using the Report a Problem tool. 使用此工具时,可发送我们诊断和修复问题所需的遥测数据和日志。When you use this tool, you can send us the telemetry and logs we need to help us diagnose and fix the problem.

对于安装相关问题,我们还提供实时聊天(仅限英语)支持选项。We also offer a live chat (English only) support option for installation-related issues.

我们还提供其他支持选项。We have other support options available, too. 若要查看列表,请参阅反馈页面。For a list, see our Feedback page.

请参阅See also