> ## 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.

# 在不安裝 GDK 的情況下設定建置環境

> 說明在不安裝 Microsoft Game Development Kit (GDK) 的情況下設定建置環境的流程。

# 在不安裝 Microsoft Game Development Kit 的情況下設定建置環境

本主題說明如何在解壓縮的 Microsoft Game Development Kit (GDK) 中設定建置環境和命令提示字元,因為在解壓縮 Microsoft Game Development Kit (GDK) 之後,需要額外的步驟才能使其正常運作。

## 環境變數命令檔

Microsoft Game Development Kit (GDK) 中包含一組用來定義環境變數的 .cmd 檔案。若要正確建立可存取命令列操作 (包括使用 MSBuild 建置) 的命令提示字元,就需要這些檔案。

這些 .cmd 檔案有兩個執行個體。您可以在下列範例解壓縮檔案位置中找到它們。

* C:\ExtractedGDK\220300\Microsoft GDK\Command Prompts\GamingXboxVars.cmd
* C:\ExtractedGDK\220300\Microsoft GDK\Command Prompts\GamingDesktopVars.cmd

檢查這些檔案有助於深入了解環境變數的定義和偵測方式。大部分的環境變數都是根據 IF NOT 檢查來設定,因此如果在執行之前已設定,就可以覆寫它們。

第一個輸入變數 %1 用來決定平台和 Visual Studio 版本。可用的值如下:

* GamingXboxVS2019
* GamingXboxVS2022
* GamingXboxScarlettVS2019
* GamingXboxScarlettVS2022
* GamingDesktopVS2019
* GamingDesktopVS2022

此用法的範例 (從命令列) 為 GamingXboxVars.cmd GamingXboxVS2022。

這會設定一個命令提示字元,其環境變數已定義為搭配 XBOX 和 Visual Studio 2022 使用。下列各節詳細說明必須覆寫哪些環境變數,才能設定參考解壓縮套件檔案的命令提示字元。

<Note>
  對於 GDK 新版面配置,參數名稱為:GamingXboxGen8VS2019、GamingXboxGen8VS2022、GamingXboxGen9VS2019、GamingXboxGen9VS2022、GamingWindowsVS2019 或 GamingWindowsVS2022。
</Note>

## Gaming.Xbox.XboxOne.x64 和 Gaming.Xbox.Scarlett.x64 的環境變數設定

在 Microsoft Game Development Kit (GDK) 命令提示字元中呼叫 **GamingXboxVars.cmd** 之前,應先設定下列環境變數,以參考解壓縮的位置並覆寫本機安裝檢查。

* **GXDKEDITION:** Gaming XBOX Development Kit (GXDK) 的版本號碼。例如,220300 代表 2022 年 3 月的 Microsoft Game Development Kit (GDK)。
* **GameDK:** Microsoft Game Development Kit (GDK) 的根位置。
* **GameDKLatest:** 根位置下的最新版本號碼資料夾。
* **WindowsSdkDir:** Windows 10 SDK 的位置。
* **GamingGRDKBuild:** Gaming Runtime Development Kit (GRDK) 特定檔案的位置。
* **GamingGXDKBuild:** Microsoft Game Development Kit (GDK) 特定檔案的位置。
* **VSInstallDir:** Visual Studio 安裝的位置。

將這些環境變數設定為指向範例解壓縮檔案的範例命令如下。

```cmd theme={null}
SET GXDKEDITION=220300
SET "GameDK=C:\ExtractedGDK\%GXDKEDITION%\Microsoft GDK\"
SET "GameDKLatest=%GameDK%%GXDKEDITION%\"
SET "WindowsSdkDir=C:\ExtractedWin10SDK\Windows Kits\10\"
SET "GamingGRDKBuild=%GameDKLatest%GRDK\"
SET "GamingGXDKBuild=%GameDKLatest%GXDK\"
SET "VSInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\"
```

使用上一節所述的 **GamingXboxVars.cmd** 輸入變數,在 XBOX One 和 XBOX Series X|S 環境之間切換。

## Gaming.Desktop.x64 的環境變數設定

在 Microsoft Game Development Kit (GDK) 命令提示字元中呼叫 **GamingDesktopVars.cmd** 之前,應先設定下列環境變數,以參考解壓縮的位置並覆寫本機安裝檢查。

* **GRDKEDITION:** Gaming Runtime Development Kit (GRDK) 的版本號碼。例如,220300 代表 2022 年 3 月的 Microsoft Game Development Kit (GDK)。
* **GameDK:** Microsoft Game Development Kit (GDK) 的根位置。
* **GameDKLatest:** 根位置下的最新版本號碼資料夾。
* **WindowsSdkDir:** Windows 10 SDK 的位置。
* **GamingGRDKBuild:** Gaming Runtime Development Kit (GRDK) 特定檔案的位置。
* **VSInstallDir:** Visual Studio 安裝的位置。

將這些環境變數設定為指向範例解壓縮檔案的範例命令如下。

```cmd theme={null}
SET GRDKEDITION=220300
SET "GameDK=C:\ExtractedGDK\%GRDKEDITION%\Microsoft GDK\"
SET "GameDKLatest=%GameDK%%GRDKEDITION%\"
SET "WindowsSdkDir=C:\ExtractedWin10SDK\Windows Kits\10\"
SET "GamingGRDKBuild=%GameDKLatest%GRDK\"
SET "VSInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\"
```

## 命令提示字元設定

安裝 Microsoft Game Development Kit (GDK) 時,命令提示字元會建立為指向適當 Microsoft Game Development Kit (GDK) 命令提示字元 .cmd 檔案的捷徑。範例如下。

`C:\Windows\System32\cmd.exe /k "C:\ExtractedGDK\220300\Microsoft GDK\Command Prompts\GamingXboxVars.cmd" GamingXboxVS2022`

使用上述內容建立捷徑,將提供與已安裝之命令提示字元指令碼相同的環境設定。建議的設定方式是包裝一個指令碼,先設定上述環境變數,然後以適當的輸入變數執行此命令。

## 來自 Microsoft Game Development Kit (GDK) 的 Lib 和 Include 參考

環境變數指令碼會為 Lib 和 Include 路徑設定下列位置。下列 Gaming.Xbox.Scarlett.x64 範例僅供參考,不應覆寫 (在此範例中,MSVC Tools 版本衍生自 VCToolsVersion 環境變數)。

```cmd theme={null}
INCLUDE=C:\Program Files (x86)\Windows Kits\10\Include\um;C:\Program Files (x86)\Windows Kits\10\Include\shared;C:\Program Files (x86)\Windows Kits\10\Include\winrt;C:\Program Files (x86)\Windows Kits\10\Include\cppwinrt;C:\Program Files (x86)\Windows Kits\10\Include\ucrt;C:\ExtractedGDK\220300\Microsoft GDK\220300\GXDK\gamekit\include\Scarlett;C:\ExtractedGDK\220300\Microsoft GDK\220300\GXDK\gamekit\include;C:\ExtractedGDK\220300\Microsoft GDK\220300\GRDK\gamekit\include;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.30.30705\INCLUDE;

LIB=C:\Program Files (x86)\Windows Kits\10\Lib\um\x64;C:\Program Files (x86)\Windows Kits\10\Lib\ucrt\x64;C:\ExtractedGDK\220300\Microsoft GDK\220300\GXDK\gamekit\lib\amd64\Scarlett;C:\ExtractedGDK\220300\Microsoft GDK\220300\GXDK\gamekit\lib\amd64;C:\ExtractedGDK\220300\Microsoft GDK\220300\GRDK\gamekit\lib\amd64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.30.30705\lib\x64;

LIBPATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\
```

## 來自 Windows 10 SDK 的 Lib 和 Include 參考

環境變數指令碼會為 Windows 10 SDK 的 Lib 和 Include 路徑設定下列位置。下列範例僅供參考,不應覆寫。

```cmd theme={null}
WindowsIncludeRoot=C:\Program Files (x86)\Windows Kits\10\Include\
WindowsLibRoot=C:\Program Files (x86)\Windows Kits\10\Lib\
```

## 另請參閱

* [在不安裝 Microsoft Game Development Kit 的情況下設定專案](/zh-TW/build/console-features/build-without-install/project-configuration-withoutinstall)
* [在不安裝 Microsoft Game Development Kit 的情況下建置的概觀](/zh-TW/build/console-features/build-without-install/withoutinstall-overview)


## Related topics

- [NDA 主題目錄 - Microsoft Learn 線上連結](/zh-TW/nda/nda-topic-directory.md)
- [PC 遊戲開發的 Visual Studio 專案範本](/zh-TW/tools/tools-pc/visualstudio/gr-vs-templates.md)
- [在 Unity 中不使用編輯器延伸模組安裝 PlayFab SDK](/zh-TW/services/playfab/sdks/unity3d/installing-unity3d-sdk.md)
- [為 XBOX Series X|S 與 XBOX One 設定 Visual Studio](/zh-TW/tools/tools-console/visualstudio/vs-cross-gen.md)
- [安裝 GDK 工具鏈](/zh-TW/home/setup-install/download-install.md)
