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

# 開始為 XBOX 主機封裝遊戲

> 開始為 XBOX 主機封裝遊戲

請使用下列步驟建立 XVC 套件，您可以將其側載到 Microsoft Game Development Kit 上進行測試，然後提交至 Partner Center 以進行發佈。

## 從 Partner Center 取得您的產品身分識別資訊

您的套件會參考 Partner Center 中指派給遊戲的產品身分識別，包括您的發行者身分識別、PackageFamilyName、MSAAppId 和 TitleId。請設定您的產品，並從 **Game Setup | Identity** 頁面擷取這些資訊，以便在 MicrosoftGame.config 中使用。

1. 如果您尚未這麼做，請[註冊 ID@XBOX 計畫](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/tutorials/pc-e2e-guide/e2e-register-id-at-xbox)並[建立 Partner Center 帳戶](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/tutorials/pc-e2e-guide/e2e-creating-partnercenter-account)。
2. 在 Partner Center 中為您的遊戲[建立初始產品定義](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/tutorials/pc-e2e-guide/e2e-creating-partnercenter-product-definition)。
3. 在產品的 **Game Setup | Identity** 頁面上，找到上述的身分識別值。

## 在根資料夾中建立 MicrosoftGame.config 檔案，並與其餘遊戲內容放在一起

本文稍後會提供 MicrosoftGame.config XML 範例檔案。請將此範例與 [MicrosoftGame.config 編輯器](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Editor)搭配作為參考，該編輯器可簡化 .config 檔案的建立，並自動從您的 Partner Center 專案同步 ID 和名稱值。

## 建立要在殼層和 Microsoft Store 套件中顯示的圖示

針對下列 MicrosoftGame.config 範例中列出的每個影像，請在遊戲的根資料夾中放置對應的檔案，並縮放為指定的大小。或者，您也可以將影像資產放在子目錄中，並調整 `ShellVisuals` 圖示路徑以符合。[MicrosoftGame.config 編輯器](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Editor)可讓您以單一來源影像作為輸入，為您產生這些影像。

## 安裝 Microsoft Game Development Kit (GDK) (包含 makepkg.exe 封裝工具)

根據預設，Microsoft Game Development Kit (GDK) 命令提示字元位於此資料夾中：`C:\Program Files (x86)\Microsoft GDK\Command Prompts`

## 建立封裝配置對應檔案

在包含單一資料夾 (其中有您所有遊戲內容) 的資料夾中開啟 Microsoft Game Development Kit (GDK) 命令提示字元，然後執行下列命令：

`makepkg genmap /f layout.xml /d <Your_Game_Folder>`

## 建立您的套件

### 如何建立您的套件

請依照下列步驟建立 `/lk` 加密套件：

1. 一次性作業：執行 `makepkg genkey /ekb SECRET_KEY.lekb` 以建立 `SECRET_KEY.lekb` 檔案。此檔案是本機託管金鑰 Blob (LEKB)，用來儲存加密您套件的穩定內容金鑰。請將其儲存在安全的位置，並僅授予有必要知道的人員存取權。在理想的設定中，只有正式的組建電腦和帳戶才應具有其存取權。
2. 建立套件：執行 `makepkg pack /lk SECRET_KEY.lekb /f layout.xml /d <Your_Game_Folder_Name> /pd <Output_Folder_Name>`。此命令會使用儲存在 SECRET\_KEY.lekb 檔案中的金鑰，建立加密的套件。

### 套件加密的重要注意事項

`makepkg` `/lk` 參數會使用 `makepkg genkey` 命令所建立的穩定 (一律相同) 金鑰來加密套件。除了您的遊戲套件之外，`makepkg /lk` 還會產生名稱格式為 *PackageFullName\_licenseName\_GUID.EKB* 和 *PackageFullName\_licenseName\_GUID.CEKB* 的檔案。(請注意底線 (\_) 字元的使用方式。)

請在主機上使用 `/lk` 加密進行開發套件測試和提交。與測試加密 (`/lt`) 和提交加密 (`/l`) 相比，它提供下列優點：

1. `packageutil compare` 可以產生正確的更新大小估計值 (與 `/l` 不同)。
2. 它會使用主機和 PC 下載內容更新時所使用的相同演算法，啟用安全的差異上傳至 Partner Center。
3. 您可以將其安裝到開發套件上 (與 `/l` 不同)。
4. 它使用安全的加密金鑰資料，而且您只能在特定環境中將其解密 (與 `/lt` 不同)。

## 測試您的套件安裝

使用下列命令測試您的套件安裝：

`xbapp install <Your_Package>`

如果您的套件使用 Intelligent Delivery 功能，請使用 `/i` 選項叫用互動式殼層 UI，以挑選要安裝哪些套件功能，用於測試零售使用者體驗。

`xbapp install /i <Your_Package>`

### 套件安裝的重要注意事項

`xbapp install` 會自動安裝將套件載入 XBOX 開發套件所需的 CEKB 檔案。如果您要測試以工具為基礎的安裝以外的安裝情境 (遊戲光碟、外部儲存體、主機對主機傳輸)，則可以使用 `xbapp installkey` 命令只安裝 CEKB 檔案。如需詳細資訊，請參閱 [xbapp.exe](/zh-TW/tools/tools-console/commandlinetools/xbapp)。

<Info>
  在 2021 年 4 月 GDK 之前產生的 LEKB 檔案不會建立 CEKB 檔案。若要使用新的開發套件側載功能，必須使用 2021 年 4 月或更新版本的 GDK 工具重新建立 LEKB 檔案。
</Info>

### 如果您打算為套件建立光碟，請參閱下列文章

[建立測試合輯光碟](/zh-TW/build/core-features/common/packaging/creating-test-compilation-discs) [建立跨世代測試光碟](/zh-TW/build/core-features/common/packaging/creating-cross-gen-test-discs)

## 將您的套件提交至 Microsoft Partner Center

由於使用了 `/lk` 旗標來加密套件，因此使用先前 makepkg.exe 命令建立的套件可同時用於測試和提交。上傳此套件時，您也能受益於差異上傳。XVC 和 EKB 檔案會照常上傳至 Partner Center。LEKB 和 CEKB 檔案則不會上傳。

## MicrosoftGame.config 範例

建立名為 MicrosoftGame.config 的檔案。在遊戲內容的根目錄中使用下列內容，然後移除您不需要之項目的註解。如需詳細資訊，請參閱 [MicrosoftGame.config 參考頁面](/zh-TW/reference/system/microsoftgameconfig/microsoftgameconfig-schema)。

雖然您可以手動建立 MicrosoftGame.config，但建立此檔案的最佳方式是使用 [MicrosoftGame.config 編輯器](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-Editor)。

```xml theme={null}
<?xml version="1.0" encoding="utf-8"?>
<Game configVersion="1">
    <!-- Publisher should match the exact value provided in the "Package/Identity/Publisher" field of the Game setup -> Identity section of your product's configuration area in Partner Center.
         Name should match the exact value provided in the "Package/Identity/Name" field of the Game setup -> Identity section of your product's configuration area in Partner Center. -->
    <Identity Name="**REPLACE**"
        Publisher="**REPLACE**"
        Version="1.0.1.0"/>
        <!-- For MSIXVC/MSIXVC2 the fourth digit of the version number is reserved for Microsoft Store use -->

    <!-- These values are found in the Game Setup -> Identity section in your product's configuration area in Partner Center. -->
    <StoreId>**REPLACE WITH STOREID**</StoreId>
    <MSAAppId>**REPLACE WITH MSAAPPID**</MSAAppId>
    <TitleId>**REPLACE WITH TITLEID**</TitleId>

     <!-- Use OverrideDisplayName if you want to display a different title in the shell than the DefaultDisplayName from the ShellVisuals section, or if you need to localize it. 
          Use TargetDeviceFamily to specify what platform your executable is built for (NOTE: Packaging will only allow one TargetDeviceFamily type to be specified to properly build a package. For more information, see the above reference page.) -->
    <ExecutableList>
      <Executable Name="**REPLACE**"
                  Id="Game"
                  OverrideDisplayName="**REPLACE**"
                  TargetDeviceFamily="XboxOne"
                  />
    </ExecutableList>

    <!-- DefaultDisplayName should match the exact value provided in the "Package/Identity/Name" field of the Game setup -> Identity section of your product's configuration area in Partner Center.
         PublisherDisplayName should use the exact value provided in the "Package/Properties/PublisherDisplayName" field of the Game setup -> Identity section of your product's configuration area in Partner Center.-->

    <!-- The following asset sizes apply
         StoreLogo - 100x100
         Square150x150Logo - 150x150
         Square44x44Logo - 44x44
         SplashScreenImage - 1920x1080
    -->
    <ShellVisuals DefaultDisplayName="**REPLACE**" 
                  PublisherDisplayName="**REPLACE**"
                  StoreLogo="StoreLogo.png"
                  Square150x150Logo="Logo.png"
                  Square44x44Logo="SmallLogo.png"
                  Description="**REPLACE**"
                  BackgroundColor="#000040"
                  SplashScreenImage="SplashScreen.png"/>
</Game>
```

## 相關的封裝文章

[開始為 PC 封裝遊戲](/zh-TW/build/core-features/common/packaging/overviews/packaging-getting-started-for-PC) [MicrosoftGame.Config](/zh-TW/build/core-features/common/game-config/MicrosoftGameConfig-toc) [將您的遊戲部署到 XBOX 開發套件](/zh-TW/home/setup-install/concepts/deployment)


## Related topics

- [XBOX Series X|S 總覽](/zh-TW/paths/series-xs/overview.md)
- [XBOX 主機遊戲的認證測試 XBOX 需求](/zh-TW/publishing/certification/console-cert-tested-requirements.md)
- [使用 GDKX 建置並執行你的第一個主機遊戲](/zh-TW/home/build-first-title/first-console-title-walkthrough.md)
- [GDK 名詞與縮寫詞彙表](/zh-TW/home/glossary.md)
- [移植總覽](/zh-TW/paths/porting/overview.md)
