> ## 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 支援注意事項

> Visual Studio 2019 支援注意事項

本主題說明 Microsoft Game Development Kit (GDK) 對 Visual Studio 2019 的支援。Visual Studio 2019 [16.11 版](https://learn.microsoft.com/visualstudio/releases/2019/servicing-vs2019)支援 Microsoft Game Development Kit (GDK) 開發。

<Note>Visual Studio 2019 16.0 - 16.10 版已於 2022 年 10 月終止支援。</Note>

## 安裝 Visual Studio 2019

安裝 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" />

除了 Windows PC 遊戲開發所需的核心 C++ 工具之外，使用 C++ 的遊戲開發也包含使用 Microsoft Game Development Kit (GDK) 建置 Windows PC 遊戲所需的 Windows 10 SDK 版本。

雖然並非必要，但安裝使用 C++ 的桌面開發工作負載可提供您可能覺得有用的其他工具與範例。

視您的需求而定，您可以選擇安裝其他選用工作負載或元件。

* 如果您正在建置使用 Unity 的遊戲，請安裝 **使用 Unity 的遊戲開發** 工作負載。

* MVSC 建置工具的 **v142** 版本會隨使用 C++ 的遊戲開發工作負載一起安裝。如有需要，您可以搭配 Visual Studio 2017 (**v141**) 中隨附的 MSVC 工具使用 Visual Studio 2019 整合式開發環境 (IDE)。使用較新的 IDE 而不升級至新的工具組，可讓您利用新的 IDE 功能，而不必更新原始程式碼以搭配新的編譯器運作。

> 若要搭配 Visual Studio 2019 IDE 使用 Visual Studio 2017 工具組，請安裝 **使用 C++ 的桌面開發** 工作負載底下的 **MSVC v141 - VS 2017 C++ x64/x86 build tools (v14.16)** 元件，如下列螢幕擷取畫面所示。自 2024 年 10 月版本起，不再支援 Visual Studio 2017 工具組。

* 若要在遠端電腦上偵錯遊戲，請參閱[在 Visual Studio 中遠端偵錯 C++ 專案](https://learn.microsoft.com/visualstudio/debugger/remote-debugging-cpp)，以取得安裝 Visual Studio 遠端工具的指示。

## 將現有的 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. 將 `WindowsTargetPlatformVersion` 新增至 `Globals` 屬性群組。將其值設為 10.0。以下是範例。

```xml theme={null}
      <PropertyGroup Label="Globals">
        <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
        ...
```

1. 將所有 `PlatformToolset` 執行個體從 v141 變更為 v142。以下是範例。

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

1. 重建專案。

### 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)](/zh-TW/tools/tools-pc/visualstudio/gr-vs-clang) Clang 主題與 [Microsoft Docs](https://learn.microsoft.com/cpp/build/clang-support-msbuild)。

## 已知問題

* 使用 `/fp:fast` 建置時，DirectXMath \*IsNan 函式在 Visual Studio 2019 中可能會失敗。修正方式是搭配 DirectXMath 3.14 或更新版本使用 Visual Studio 2019 (16.3 或更新版本)。否則，您可以在使用這些函式的位置周圍放置 `#pragma float_control` 陳述式來因應此問題。

* 在 v11 之前的 clang/LLVM for Windows 中，使用先行編譯標頭會有許多問題。視您的 PCH 與 C++ 範本使用方式而定，您可能需要新增 `-fno-pch-instantiate-templates` 才能成功建置。

* [透過 Microsoft Update 提供的 .NET Core 更新](https://devblogs.microsoft.com/dotnet/net-core-updates-coming-to-microsoft-update/)可能會封鎖 Microsoft Game Development Kit (GDK) 安裝。若要解決此問題，請更新您的 Visual Studio 執行個體，或透過 Visual Studio 安裝程式解除安裝 Microsoft.NET.Core.Component.SDK.2.1 元件，然後重試安裝 (或解除安裝) Microsoft Game Development Kit (GDK)。

## 回報錯誤

**Visual C++ 編譯器**的錯誤報告應 (盡可能) 透過 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)網站。請務必閱讀[此頁面](https://aka.ms/compilerbug)，以了解如何為編譯器建立良好錯誤報告的詳細資訊。

<Note>如果需要其他 NDA 資訊才能重現問題，您可以在公開報告問題中新增標示為「僅限 Microsoft」的註解。</Note>

若要回報 **clang/LLVM for Windows 編譯器**的錯誤，請使用 [https://bugs.llvm.org/](https://bugs.llvm.org/)

若要回報 **Microsoft 標準 C++ 程式庫** (又稱 STL) 的錯誤，請使用 [https://github.com/microsoft/STL/issues](https://github.com/microsoft/STL/issues)

## 另請參閱

[PC 遊戲開發的 Visual Studio](/zh-TW/tools/tools-pc/visualstudio/gr-visualstudio-toc)


## Related topics

- [Visual Studio](/zh-TW/tools/tools-pc/visualstudio/index.md)
- [Visual Studio (內容)](/zh-TW/tools/tools-pc/visualstudio/gr-visualstudio-toc.md)
- [用於主機開發的 Visual Studio](/zh-TW/tools/tools-console/visualstudio/visualstudio.md)
- [Visual Studio 2019 GDK 支援注意事項](/zh-TW/tools/tools-console/visualstudio/vs-2019-support-notes.md)
- [Visual Studio 2026 GDK 支援注意事項](/zh-TW/tools/tools-console/visualstudio/vs-2026-support-notes.md)
