使用 MSIXVC 包装工具包装面向电脑的游戏入门

使用下面的步骤创建 MSIXVC 包,此包可供在目标测试开发电脑上旁加载以进行测试,然后将其提交到合作伙伴中心进行发布。

检查 Windows 10 版本的最低要求

要对基于 MSIXVC 的包进行部署测试,需要 Windows 10 版本 18362 或更高版本。

评估包装需求

如果包具有任何以下属性或需要任何以下功能,请参阅本话题后面的 其他包装注意事项和高级功能 部分。

  • 框架包依赖项
    如果应用依赖于可再发行软件,则可以使用 Microsoft 的许多以下先决条件的预包装版本,它们可以声明为依赖项并自动安装。

  • 自定义安装操作
    如果应用依赖于没有框架包可用的可再发行软件,则可以链式安装这些依赖项。

准备内容

将游戏的所有源资料都放在一个目录中。 请确保您删除任何与 MSIXVC 包装系统不兼容或不适合在零售包中附带的文件。

  • PDB 文件。

  • 通用 Windows 平台 (UWP) 和 Appx“占用空间”文件,包括 AppxSignature.p7x 和 AppxBlockMap.xml。
    如果以前已在 Microsoft Store 中发布为 UWP,可能有一些文件与 Appx 或 MSIX 包关联,必须删除这些文件。

  • 对其他电脑游戏商店的任何引用:资产、二进制文件等等。

从合作伙伴中心获取产品的标识信息

与 Microsoft 代表一起在合作伙伴中心创建您的产品。 这是执行下一步的先决条件,这需要知道发布者标识和包名称。 有关此步骤的详细信息超出了本话题的讨论范围,您可能需要得到 Microsoft 代表的协助。

在根文件夹中创建 MicrosoftGame.config xml 文件,然后创建游戏内容的剩余部分

本主题后面 提供了一个示例 MicrosoftGame.config xml 文件。 这可以用作参考,同时使用 MicrosoftGame.config 编辑器,它可以简化 .config 文件的创建,并自动从合作伙伴中心项目中同步 ID 和名称值。

确定任何 Visual C/C++ 运行时依赖项

确定包的任何 Visual C/C++ 运行时依赖项。 建议您确保它们在 MicrosoftGame.config 中列出为依赖项或明确复制到包负载。 有关详细信息,请参阅 框架包依赖项

创建图标以显示在 shell 中并存储包

对于以下 MicrosoftGame.config 示例中列出的每个图像,在游戏的根文件夹中放入相应的文件(可缩放到指定的大小)。 或者,可以将图像资产放置在子目录中,并调整 ShellVisuals 图标路径以进行匹配。 MicrosoftGame.config 编辑器提供生成具有单个源映像作为输入的映像的功能。

安装 Microsoft 游戏开发工具包,它包含了 MakePkg.exe 打包工具

默认情况下,Microsoft 游戏开发工具包 (GDK) 命令提示位于以下文件夹中:
C:\Program Files (x86)\Microsoft GDK\Command Prompts

创建包装布局映射文件

在包含具有所有游戏内容的单个子文件夹的文件夹中打开 Microsoft 游戏开发工具包 (GDK) 命令提示符,并运行以下命令:

MakePkg genmap /f layout.xml /d <Your_game_folder>

这会创建一个名为 layout.xml 的文件(这是推荐的名称,可以使用任何其他名称),该文件在打包步骤中使用。 有关打包工具的详细信息,请参阅 Make 包 (makepkg.exe)

使用智能交付来确定如何减少安装大小

要了解如何通过标记 layout.xml 文件中的内容减少安装大小,请参阅智能交付概述。 如果您有大小可调的本地化资产或内容,它们在默认情况下不应安装但在游戏触发时应可供下载,请考虑使用智能交付。

创建包

使用以下命令创建包:

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

请注意,对于依赖于许可的(例如游戏内商店、试用版)场景,将需要使用带实际内容 ID 的 MakePkg。 此真实内容 ID 将在合作伙伴中心中第一次引入此包时生成,并且可在“程序包”页面中的已提交包的详细信息中找到。

在目标电脑上启用开发者模式

  1. 打开设置。

  2. 在搜索字段中输入开发者。 从显示的选项,选择使用开发者功能

  3. 选择开发者模式。 显示一个对话框,指出系统正在添加某些功能。 在移出这一步之前,等待此过程完成。

测试应用安装

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

包必须存在于开发电脑的本地驱动器上或映射到驱动器盘号的网络位置上。 尚不支持从通用命名约定 (UNC) 共享中安装。 请注意,如果您未看到进度,可以打开 Microsoft Store 应用并在“下载和更新”部分中查看进度(进度由位于应用右上角的向下箭头指示)。 还可以通过单击省略号“...”然后选择下载和更新来查看进度。

自 2022 年 3 月 Microsoft 游戏开发工具包 (GDK) 起,MSIXVC 包将安装到 [drive]:\XboxGames 文件夹中,该文件夹布局为可直接修改和访问的平面文件。 应用程序管理 (wdapp.exe) 可以配置此驱动器位置。 有关平面文件安装功能的详细信息,请参阅平面文件安装概述

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

通过使用上面的 MakePkg.exe 命令创建的包使用了/LT 参数,该参数使用测试/开发密钥进行加密。 为实现最高安全性,请使用 /LK 标志再次运行 MakePkg.exe 命令,以便使用稳定密钥对参数进行加密,或者使用 /L 标志运行命令,以使用唯一密钥对参数进行加密。 建议使用 /LK 而不使用 /L,因为使用 /LK 创建的包可用于本地大小增量比较,并且在提交给合作伙伴中心时可受益于增量上传优化。

示例 MicrosoftGame.config

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

虽然可手动创建 MicrosoftGame.config,但最佳创建方法是使用 MicrosoftGame.config 编辑器。 此工具还允许直接从合作伙伴中心项目中简单同步标识和 ID 值。

<?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"/>
        <!-- The fourth digit of the version number is reserved for Microsoft Store use -->
    <!--  Optional: Use StoreId if your product will offer durable downloadable content (DLC) packages.
    Look up the Store ID (12-character alphanumeric string) of your main application package in the Game setup -> Identity section of your product's configuration area in Partner Center. (Example: 9PNX12345AAA)
    <StoreId>**REPLACE WITH STOREID**</StoreId> -->

    <MSAAppId>**REPLACE WITH MSAAPPID**</MSAAppId> <!-- This value is found in the Xbox services -> Xbox Settings section in your product's configuration area in Partner Center. -->
    <TitleId>**REPLACE WITH TITLEID**</TitleId> <!-- This value is found in the Game Setup -> Identity section of your product's configuration area in Partner Center. -->

    <!--  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 Store 中以框架包形式提供,则不会链式安装可再发行文件,您可以声明框架包的依赖项。

例如,如果您的应用程序使用的是一直以使用 dxsetup.exe 来自 Microsoft 下载站点的新产品 来满足的旧版 DirectX 运行时,您可以在 Windows.Universal 和 Windows.Desktop 的标准依赖项旁边,在框架包上声明一个依赖项。 这优于使用自定义安装操作直接安装该新产品,因为框架包可以通过 Microsoft Store 自动更新,并且自定义安装操作需要管理员批准并生成确认提示(作为安装过程的一部分)。

<DependencyList>
  <KnownDependency Name="DX11"/>
</DependencyList>

有关已知依赖项的完整列表,请参阅 MicrosoftGame.config 元素 - KnownDependency 的文档。

在安装时,操作系统和 Microsoft Store 确保此包依赖项已随应用安装。 有关详细信息,包括有关 DirectX 和 Visual Studio C/C++ 运行时框架包依赖项的信息,请参阅 框架包依赖项

修改支持

自 2022 年 3 月 Microsoft 游戏开发工具包 (GDK) 起,默认情况下支持 mod。 有关详细信息,请参阅 Mods

自定义安装操作

如果应用依赖于必须在安装应用时链式安装的其他安装程序(.exe 或 .msi 文件),则可以使用 CustomInstallActions 元素配置此设置。

对于可再发行文件,应检查框架包是否可用以及是否包含需要的先决条件,然后再决定将自定义安装程序用于诸如 VC 运行时或 DirectX 可再发行 .msi 或 .exe 等项目。 有关自定义安装操作的详细说明,请参阅 自定义安装操作

受限功能权限

除了配置您的 MicrosoftGame.config 文件以包含正确的元素外,您还需要向客户经理 (AM) 发送电子邮件,以便为您的游戏设置权限,使其使用以下功能。

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

另请参阅

面向 Xbox 主机的包装游戏入门
MicrosoftGame.Config
利用 Microsoft 游戏开发工具包工具安装和启动电脑游戏
电脑引导程序