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

# 使用 MSIXVC 工具打包 PC 游戏入门

> 使用 MSIXVC 打包工具进行 PC 游戏打包入门

<Tip>
  **MSIXVC2 自 2026 年 10 月 GDK 起正式可用。** MSIXVC2 是新一代 PC 打包格式，提供大幅缩减的更新、更快的打包以及简化的上传工作流。如果你正在启动新的 PC 游戏或评估打包选项，请参阅 [MSIXVC2 打包概述](/build/core-features/common/packaging/overviews/packaging-msixvc2-overview)和[针对 PC 的 MSIXVC2 入门](/build/core-features/common/packaging/overviews/packaging-getting-started-for-PC-msixvc2)。本页面的步骤适用于原始 MSIXVC 格式，该格式仍完全受支持。
</Tip>

按照以下步骤创建可在目标测试开发 PC 上旁加载测试的 MSIXVC 包，然后提交到合作伙伴中心进行发布。

## 检查 Windows 10 版本的最低要求

MSIXVC 包的部署测试需要 Windows 10 版本 18362 或更高版本。

## 评估打包需求

如果你的包具有以下任一属性或需要以下任一功能，请参阅本文后面的[其他打包考虑事项与高级功能](#other-packaging-considerations-and-advanced-features)一节。

* **框架包依赖** 如果你的应用依赖可再分发软件，可以使用 Microsoft 提供的许多此类先决条件的预打包版本，并将其声明为依赖项以便自动安装。
* **自定义安装操作** 如果你的应用依赖没有可用框架包的可再分发软件，可以链式安装这些依赖。

## 准备内容

将你游戏的所有源材料放入一个目录。移除 MSIXVC 打包系统不支持或不适合在零售包中发行的文件。

* 程序数据库 (PDB) 文件。
* 通用 Windows 平台 (UWP) 和 APPX 的 footprint 文件，包括 AppxSignature.p7x 和 AppxBlockMap.xml。如果你之前以 UWP 形式在 Microsoft 应用市场发行，可能会有一些与 APPX 或 MSIX 包相关的此类文件。请移除它们。
* 对其他 PC 游戏商店的任何引用：资源、二进制文件等。

## 从合作伙伴中心获取产品身份信息

你的包会引用在合作伙伴中心中分配给你游戏的产品身份，包括发行商身份、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)并[创建合作伙伴中心账户](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/tutorials/pc-e2e-guide/e2e-creating-partnercenter-account)。
2. 在合作伙伴中心为你的游戏[创建初始产品定义](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 XML 文件，然后创建其余游戏内容

本文后面提供了一个 MicrosoftGame.config xml 示例文件。可将此示例与 [MicrosoftGame.config 编辑器](/build/core-features/common/game-config/MicrosoftGameConfig-Editor)结合参考使用，该编辑器可简化 .config 文件的创建，并自动从合作伙伴中心项目同步 ID 和名称值。

## 识别所有 Visual C/C++ 运行时依赖项

识别包的 Visual C/C++ 运行时依赖项。确保它们已作为依赖项列在你的 MicrosoftGame.config 中或明确复制到包负载中。有关详细信息，请参阅[框架包依赖](/build/core-features/common/packaging/packaging-framework-packages)。

## 创建用于在 shell 和商店包中显示的图标

对于以下 MicrosoftGame.config 示例中列出的每个图像，请将相应文件按指定尺寸缩放后放入游戏的根文件夹。或者，将图像资源放入子目录中，并相应调整 ShellVisuals 图标路径。[MicrosoftGame.config 编辑器](/build/core-features/common/game-config/MicrosoftGameConfig-Editor)可从单个源图像生成这些图像。

## 安装包含 MakePkg.exe 打包工具的 Microsoft Game Development Kit

默认情况下，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>`

此命令会创建名为 `layout.xml` 的文件（此文件名为建议名，你也可以使用其他名称）。在打包步骤中使用此文件。有关打包工具的更多信息，请参阅 [Make package (makepkg.exe)](/build/core-features/common/packaging/deployment/makepkg)。

## 使用 Intelligent Delivery 判断如何缩减安装大小

要了解如何通过在 layout.xml 文件中为内容打标签来缩减安装大小，请参阅 [Intelligent Delivery 概述](/build/core-features/common/packaging/overviews/intelligentdelivery)。如果你有较大的本地化资源，或有默认不安装、需要由游戏触发下载的内容，可考虑使用 Intelligent Delivery。

## 创建包

使用以下命令创建包：

`MakePkg pack /f layout.xml /lt /d <Your_game_folder_name> /nogameos /pc /pd <Output_Folder_Name>`

对于依赖许可证的场景（例如游戏内商店和试用），请对 `makepkg` 使用实际的内容 ID。合作伙伴中心在首次接收包时会生成此真实内容 ID。你可以在**包**页面上已提交包的详细信息中找到它。

## 在目标 PC 上启用开发者模式

1. 打开**设置**。
2. 在搜索字段输入 **Developer**。在显示的选项中选择 **Use developer features**。
3. 选择 **Developer mode**。系统会出现一个对话框，提示正在添加某些功能。请等待此过程完成后再继续。

## 测试应用安装

运行以下命令：`Wdapp install <Your_Package.msixvc>`

包必须位于开发 PC 的本地驱动器上，或已映射到驱动器盘符的网络位置。尚不支持通过 UNC 共享安装。如果看不到进度，可打开 Microsoft 应用市场应用，在应用右上角向下箭头指示的**下载和更新**部分查看进度（如可用）；也可选择省略号 (...)，然后选择**下载和更新**。

自 2022 年 3 月的 Microsoft Game Development Kit (GDK) 起，MSIXVC 包安装到 `[drive]:\XboxGames` 文件夹，并以平铺文件方式布置，你可直接修改和访问。此驱动器位置可通过[应用程序管理 (wdapp.exe)](/tools/tools-pc/commandlinetools/gr-wdapp)配置。有关平铺文件安装功能的更多信息，请参阅[平铺文件安装概述](/build/core-features/common/packaging/packaging-flatfileinstall)。

## 准备最终包，然后提交到合作伙伴中心

之前使用 [MakePkg.exe](/build/core-features/common/packaging/deployment/makepkg) 命令创建的包使用了 **/LT** 参数，这会使用测试或开发密钥加密。为获得最大安全性，请再次运行 MakePkg.exe 命令并使用 `/LK` 标志（使用稳定密钥加密）或 `/L` 标志（使用唯一密钥加密）。使用 `/LK` 而非 `/L`，因为使用 `/LK` 创建的包可用于本地大小差异比较，并在向合作伙伴中心提交时受益于增量上传优化。

## MicrosoftGame.config 示例

创建名为 MicrosoftGame.config 的文件。在游戏内容的根目录中使用以下内容，然后移除你不需要项目的注释。

虽然你可以手动创建 MicrosoftGame.config，但最佳方式是使用 [MicrosoftGame.config 编辑器](/build/core-features/common/game-config/MicrosoftGameConfig-Editor)。此工具还可轻松地直接从合作伙伴中心项目同步身份和 ID 值。

```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>

    <!--  Include any additional languages your title supports as appropriate -->
    <Resources>
      <Resource Language="en-US" />
    </Resources>

     <!-- Use override display name 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. -->

     <!-- Configuring the Alias attribute will allow you to take advantage of Execution Alias functionality when launching your executable. For more information, please see the MicrosoftGame.config reference documentation. -->

    <ExecutableList>
      <Executable Name="**REPLACE**"
                  Id="Game"
                  Alias="**REPLACE**"
                  OverrideDisplayName="**REPLACE**"
                  />
    </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"/>
    
    <DesktopRegistration>
      <!-- Include this section if you need to run a custom installer action with Administrator privileges the first time that your game runs.
           Any executable you specify must be located under the "Installers" folder in the base folder of your game. Don't include any other files in the
           Installers folder.
      <CustomInstallActions>
        <Folder>Installers</Folder>
        <InstallActionList>
          <InstallAction File="CustomInstaller.exe" Name="UniqueInstallTaskName" Arguments="/silent /example" />
        </InstallActionList>
      </CustomInstallActions>
      -->
      <DependencyList>
        <!-- Omit the Dependency items if your game doesn't need them, or the entire DependencyList element. Note that your version of VCLibs may be different. See the Framework package dependencies topic of the documentation for details and guidance. -->
        <KnownDependency Name="VC11"/>
      </DependencyList>
        <!-- Select the ProcessorArchitecture that matches your game executables. -->
      <ProcessorArchitecture>x64</ProcessorArchitecture>
      <!--<ProcessorArchitecture>x86</ProcessorArchitecture>-->

      <!-- Include this section if your game uses Xbox services Multiplayer invites.
      <MultiplayerProtocol>true</MultiplayerProtocol>
      -->
    </DesktopRegistration>

    <!-- Include this section if your game writes files to its installation directory, and you're unable to change this by altering your source code and recompiling your game.
    <ExtendedAttributeList>
      <ExtendedAttribute Name="RestrictedCapability" Value="packageWriteRedirectionCompatibilityShim"/>
    </ExtendedAttributeList>
    -->
</Game>
```

## 其他打包考虑事项与高级功能

### 面向常见软件依赖的框架包

如果你的应用依赖某种可再分发软件，且该软件在 Microsoft 应用市场中作为框架包提供，请声明对该框架包的依赖，而不是链式安装可再分发组件。

例如，如果你的应用使用旧版 DirectX 运行时（以前通过 [Microsoft 下载站点的 dxsetup.exe](https://www.microsoft.com/download/details.aspx?id=35) 提供），请与标准的 Windows.Universal 和 Windows.Desktop 依赖一起声明对该框架包的依赖，如下所示。此方式优于通过自定义安装操作直接安装 redist，因为框架包可通过 Microsoft 应用市场自动更新，而自定义安装操作需要管理员批准并会在安装过程中产生确认提示。

```xml theme={null}
<DependencyList>
  <KnownDependency Name="DX11"/>
</DependencyList>
```

有关已知依赖的完整列表，请参阅 [MicrosoftGame.config 元素 - KnownDependency](/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-knowndependency)的文档。

安装时，操作系统和 Microsoft 应用市场会确保此包依赖与你的应用一同安装。有关详细信息（包括 DirectX 和 Visual Studio C/C++ 运行时框架包依赖），请参阅[框架包依赖](/build/core-features/common/packaging/packaging-framework-packages)。

### mod 支持

自 2022 年 3 月的 Microsoft Game Development Kit (GDK) 起，默认支持 mod。有关详细信息，请参阅 [mod](/build/core-features/common/packaging/packaging-mods)。

### 自定义安装操作

如果你的应用依赖其他必须在应用安装时链式安装的安装程序（.exe 或 .msi 文件），请使用 CustomInstallActions 元素配置此步骤。

对于可再分发组件，在决定为诸如 VC 运行时或 DirectX 可再分发 .exe 或 .msi 文件使用自定义安装程序之前，请检查是否存在包含所需先决条件的框架包。有关自定义安装操作的详细说明，请参阅[自定义安装操作](/build/core-features/common/packaging/packaging-custom-install-actions)。

### 受限能力权限

除了配置 MicrosoftGame.config 文件以包含正确元素之外，还需要发邮件给你的客户经理启用为你的游戏使用以下功能的权限。

* 自定义安装操作 (CustomInstallActions 元素)。

## 相关打包文章

[MSIXVC2 打包概述](/build/core-features/common/packaging/overviews/packaging-msixvc2-overview) [针对 PC 的 MSIXVC2 入门](/build/core-features/common/packaging/overviews/packaging-getting-started-for-PC-msixvc2) [XBOX 主机游戏打包入门](/build/core-features/common/packaging/overviews/packaging-getting-started-for-console) [MicrosoftGame.Config](/build/core-features/common/game-config/MicrosoftGameConfig-toc) [利用 Microsoft Game Development Kit 工具安装并启动 PC 游戏](/tools/tools-pc/launching-on-pc) [PC 引导程序](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/pc-dev/overviews/gr-pc-bootstrapper)


## Related topics

- [使用 GDK 工具安装并启动 PC 游戏](/zh-CN/tools/tools-pc/launching-on-pc.md)
- [针对 PC 的 MSIXVC2 打包入门](/zh-CN/build/core-features/common/packaging/overviews/packaging-getting-started-for-PC-msixvc2.md)
- [打包](/zh-CN/build/core-features/common/packaging/gc-packaging-toc.md)
- [创建游戏包并在合作伙伴中心上传](/zh-CN/publishing/game-publishing/tutorial-xbox-managed/how-to-create-a-package.md)
- [框架包依赖](/zh-CN/build/core-features/common/packaging/packaging-framework-packages.md)
