> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Visual Studio 2019 GDK 支持说明

> Visual Studio 2019 Microsoft Game Development Kit (GDK) 支持说明

本文介绍 Microsoft Game Development Kit (GDK) 对 Visual Studio 2019 的支持情况。Visual Studio 2019 [16.11 版本](https://learn.microsoft.com/visualstudio/releases/2019/servicing-vs2019)支持 GDK 开发。

<Note>
  Visual Studio 2019 的 16.0 至 16.10 版本自 2022 年 10 月起已停止支持。16.11 版本也已退出主流支持。
</Note>

## 安装 Visual Studio 2019

GDK 支持使用 Visual Studio 2019 的 **Professional** 版或 **Enterprise** 版进行开发。不支持 Community 版。安装 Visual Studio 2019 时，请在安装过程中选择 **使用 C++ 的游戏开发** 工作负载，如下面的截图所示。

<img src="https://mintcdn.com/microsoft-4404708b/NsRUQ49ZRpXgoZ9R/images/gdk/tools/vs_workloads_game_devlopment.png?fit=max&auto=format&n=NsRUQ49ZRpXgoZ9R&q=85&s=4fb4b71036246e053fa20ee3270bb27b" alt="“使用 C++ 的游戏开发”工作负载对话框截图" width="403" height="84" data-path="images/gdk/tools/vs_workloads_game_devlopment.png" />

除了游戏开发所需的核心 C++ 工具之外，请确保安装 **Windows 10 SDK (22000)** 组件，以提供使用 GDK 构建游戏所需的 Windows SDK。也可以使用 *Windows SDK for Windows 11, Version 22H2* (10.0.22621) 或 *Windows SDK for Windows 11, Version 24H2* (10.0.26100)，但并非必需。

虽然并非必需，但安装 **使用 C++ 的桌面开发** 工作负载可提供更多有用的工具和示例。

MSVC 生成工具的 **v142** 版本会随“使用 C++ 的游戏开发”工作负载一起安装。

> 从 2024 年 10 月发行版开始，不再支持 Visual Studio 2017 的 `v141` 工具集。

### clang/LLVM for Windows (ClangCl) 项目支持

Visual Studio 2019 也支持 clang/LLVM for Windows 开发。该支持需要安装 **C++ Clang-cl for Windows** 和 **C++ Clang-cl for v142 build tools (x64/x86)**，它们是单独的组件。

有关更多信息，请参阅 [Microsoft Game Development Kit (GDK)](/tools/tools-console/visualstudio/vs-clang) Clang 文章以及 [Microsoft Docs](https://learn.microsoft.com/cpp/build/clang-support-msbuild)。

### Build Tools 版本

按照[无需完整安装的构建说明](/build/console-features/build-without-install/withoutinstall-overview)，使用 **Build Tools for Visual Studio 2019** 通过 Microsoft GDK 的头文件、库和工具进行构建。

* 使用工作负载 *使用 C++ 的桌面开发*，它会安装用于 PlatformToolset `v142` 的 Visual C++ 编译器。你也可以按本文前面说明选择 `ClangCl` 支持的组件。
* 安装 Windows SDK 或将其作为 [NuGet](https://www.nuget.org/packages/Microsoft.Windows.SDK.CPP.x64/) 包使用。

> Build Tools 版本不支持扩展，因此无法为 Build Tools 版本安装 Microsoft GDK 的 VSIX 包。这意味着它不支持部署或调试，但你仍可以使用命令行工具。

## 将现有 Visual Studio 2017 项目迁移到 Visual Studio 2019

在大多数情况下，Visual Studio 提供的升级向导可以将你的项目迁移到 Visual Studio 2019，无需其他更改。当你在 Visual Studio 2019 中打开 Visual Studio 2017 项目时，会看到以下 **查看解决方案操作** 对话框提示你升级。若要升级项目，请选择 **确定**。

<img src="https://mintcdn.com/microsoft-4404708b/6TXzXmujKayly5Sf/images/gdk/tools/vs_convert_2017_to_2019.png?fit=max&auto=format&n=6TXzXmujKayly5Sf&q=85&s=77e8e2059ed810747afecaea859027a2" alt="Visual Studio 2019 中升级向导的“查看解决方案操作”对话框截图，其中显示了 Visual Studio 2017 项目的重定目标选项" width="669" height="371" data-path="images/gdk/tools/vs_convert_2017_to_2019.png" />

你也可以选择在不升级生成工具的情况下使用 Visual Studio 2019 IDE。为此，请在 **查看解决方案操作** 对话框中选择 **取消**。

### 手动将项目升级到 Visual Studio 2019

如果你希望通过直接编辑项目文件 (.vcxproj) 来升级项目，请进行以下更改。

1. 将所有 `PlatformToolset` 实例从 `v141` 改为 `v142`。以下示例演示了此更改。

```xml theme={null}
    <PlatformToolset>v141</PlatformToolset>
    ...
    <PlatformToolset>v142</PlatformToolset>
```

1. 重新生成项目。

## 使用特定版本

默认情况下，Visual Studio 安装程序始终下载最新发行版。在企业环境中，你可以通过使用脱机布局来控制特定版本。有关更多信息，请参阅[控制 Visual Studio 部署的更新](https://learn.microsoft.com/visualstudio/install/controlling-updates-to-visual-studio-deployments)。该文章还提供了有关移除 **VS 通知** 图标的信息。

从 [Visual Studio 2019 发行版本](https://learn.microsoft.com/visualstudio/releases/2019/history) 下载特定版本的 Visual Studio 2019。

## 已知问题

* 使用 `/fp:fast` 构建时，DirectXMath 的 `*IsNan` 函数在 Visual Studio 2019 中可能失败。修复方式是使用 Visual Studio 2019 (16.3 或更高版本)。否则，你可以通过在使用这些函数处放置 `#pragma float_control` 语句来变通处理。
* GDK 开发仅支持 64 位原生编译器工具集。在 Visual C++ 的 `vcxproj` 中，可以在全局属性中设置此工具集：

```xml theme={null}
<PropertyGroup Label="Globals">
  <PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
```

* 在 clang/LLVM for Windows v11 之前的版本中，预编译头存在已知问题。根据你的 PCH 与 C++ 模板使用情况，可能需要添加 `-fno-pch-instantiate-templates` 才能成功构建。
* [通过 Microsoft Update 分发的 .NET Core 2.1 更新](https://devblogs.microsoft.com/dotnet/net-core-updates-coming-to-microsoft-update/)可能会阻止 GDK 安装。有关此问题的更多信息，请参阅 [.NET Core 2.1 支持终止通告](https://devblogs.microsoft.com/dotnet/net-core-2-1-will-reach-end-of-support-on-august-21-2021/)。要解决此问题：
  * 运行 Visual Studio 安装程序
  * 选择 Visual Studio 2019 的 **修改** 按钮
  * 选择 **单个组件** 选项卡，移除 [.NET Core 2.1 Runtime (LTS) 组件](https://learn.microsoft.com/visualstudio/install/workload-component-id-vs-enterprise)
  * 重新尝试卸载并重新安装 GDK

## 报告 Bug

对于 **Visual C++ 编译器** 的 Bug，请尽量通过 Visual Studio 的 *报告问题...* 提交。请参阅 [Microsoft Docs](https://learn.microsoft.com/visualstudio/ide/how-to-report-a-problem-with-visual-studio) 以及[开发者社区](https://aka.ms/feedback/report?space=62) 网站。有关如何为编译器创建高质量 Bug 报告的详细信息，请参阅[此页面](https://aka.ms/compilerbug)。

<Note>
  如果重现问题需要其他 NDA 信息，你可以在标记为 “Microsoft only” 的公开报告问题中添加评论。
</Note>

对于 **clang/LLVM for Windows 编译器** 的 Bug 报告，请使用 [https://bugs.llvm.org/](https://bugs.llvm.org/)

对于 **Microsoft Standard C++ Library**（也称为 STL）的 Bug 报告，请使用 [https://github.com/microsoft/STL/issues](https://github.com/microsoft/STL/issues)

一如既往，如遇需要升级处理的紧急问题，可随时联系你的 *Microsoft 联系人*。

## 另请参阅

[Visual Studio](/tools/tools-console/visualstudio/visualstudio) [Visual Studio 产品生命周期与服务](https://learn.microsoft.com/visualstudio/releases/2019/servicing-vs2019)


## Related topics

- [Visual Studio 2019 支持说明](/zh-CN/tools/tools-pc/visualstudio/gr-vs-2019-support-notes.md)
- [Visual Studio 2026 GDK 支持说明](/zh-CN/tools/tools-console/visualstudio/vs-2026-support-notes.md)
- [Visual Studio 2022 GDK 支持说明](/zh-CN/tools/tools-console/visualstudio/vs-2022-support-notes.md)
- [Visual Studio 2022 支持说明](/zh-CN/tools/tools-pc/visualstudio/gr-vs-2022-support-notes.md)
- [Visual Studio](/zh-CN/tools/tools-pc/visualstudio/index.md)
