安装程序发布

本文档介绍了如何使用游戏安装程序在 Google Play 游戏电脑版上发布游戏。

在“开发者安装”流程中,您提供的游戏安装程序必须管理游戏的安装、更新和卸载。

准备工作

将 Google Play 游戏 SDK 集成到您的游戏中。准备好开始新手入门了吗?请发送电子邮件至 google-play-games-pc@google.com。新手入门专家将协助您完成后续步骤。

将游戏打包为 WAB 文件

Google Play 游戏电脑版要求您将游戏的安装程序作为 Windows App Bundle (WAB) 文件上传到 Google Play 管理中心。如需创建 WAB 文件,请按以下步骤操作:

  1. 下载 Play 发布工具。 您可以在 Windows 命令行或 PowerShell 中运行此工具。

  2. 创建 Play 发布配置文件,并为其指定任意名称。例如,采用以下格式的 play_publishing_config.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <play-publishing-config version="1.0">
      <application>
        <package-name>PACKAGE_NAME</package-name>
        <version-name>VERSION_NAME</version-name>
      </application>
      <installer requiresElevation=INSTALLER_REQUIRES_ELEVATION acceptsCommandLineArguments=ACCEPTS_COMMAND_LINE_ARGUMENTS>
        <path>INSTALLER_PATH</path>
        <installation-path-registry-location>
          <key-name>UNIQUE_REGISTRY_PATH</key-name>
          <value-name>InstallLocation</value-name>
        </installation-path-registry-location>
      </installer>
      <launcher requiresElevation=LAUNCHER_REQUIRES_ELEVATION>
        <launch-path-registry-location>
          <key-name>UNIQUE_REGISTRY_PATH</key-name>
          <value-name>InstallLocation</value-name>
        </launch-path-registry-location>
        <executable-invocation>
          <filename>RELATIVE_PATH_TO_LAUNCHER_EXE</filename>
          <arguments>LAUNCHER_ARGS_IF_ANY</arguments>
        </executable-invocation>
      </launcher>
      <uninstaller requiresElevation=UNINSTALLER_REQUIRES_ELEVATION>
        <uninstall-path-registry-location>
          <key-name>UNIQUE_REGISTRY_PATH</key-name>
          <value-name>UninstallString</value-name>
        </uninstall-path-registry-location>
      </uninstaller>
    </play-publishing-config>

    请替换以下内容:

    • PACKAGE_NAME:游戏的软件包名称。 这是将与您在 Google Play 上的游戏相关联的唯一标识符。例如 com.yourcompany.yourgame。 软件包名称必须遵循以下规则:
      • 必须至少包含两段(一个或多个点号)。
      • 每段必须以字母开头。
      • 所有字符必须为字母数字或下划线 ([a-zA-Z0-9_])。
    • VERSION_NAME:游戏的版本字符串。这可以是任意字符串,但对于游戏的所有已上传 WAB 来说,它必须是唯一的。例如:1.0、1.0.1-beta、2025.11.24、v1.rc1。

      • INSTALLER_REQUIRES_ELEVATION:指明是否需要以管理员身份运行安装程序可执行文件才能完成安装过程。

        • "true":以管理员身份运行可执行文件。
        • "false":以当前用户身份运行可执行文件。
      • ACCEPTS_COMMAND_LINE_ARGUMENTS:一个布尔值,用于指明安装程序是否可以接受命令行参数来启用自动播放功能。此字段是可选字段,默认值为 false。如需了解详情,请参阅启用自动播放。

      • INSTALLER_PATH:WAB 中安装程序文件的路径。此路径可以是绝对路径,也可以是相对于 Google Play 发布配置父级目录的相对路径。例如,path\to\test\installer。 请务必使用 Authenticode 和代码签名为游戏的安装程序可执行文件签名。

      • <installation-path-registry-location>:Google Play 游戏用于检测游戏是否已安装的注册表路径。即使您的游戏使用自定义启动器,此路径也必须指向游戏的唯一注册表项,而不是启动器的注册表项。

      • UNIQUE_REGISTRY_PATH:Windows 注册表键路径。 此路径必须相对于注册表配置单元(例如 HKEY_LOCAL_MACHINE 或 HKEY_CURRENT_USER)提供;请勿在路径字符串中包含配置单元名称。例如,如果安装程序写入到 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\YourUniqueName,则仅指定 Software\Microsoft\Windows\CurrentVersion\Uninstall\YourUniqueName。Google Play 游戏电脑版会先在 HKEY_LOCAL_MACHINE 中搜索此路径,然后在 HKEY_CURRENT_USER 中搜索,并使用找到的第一个匹配值。

        INSTALLER_PATH 中指定的可执行文件必须创建这些注册表项。在安装完成之前,必须创建在 installation-path-registry-location、launch-path-registry-location 和 uninstall-path-registry-location 下指定的这些注册表项和值名称对。虽然示例使用的是 InstallLocation 和 UninstallString,但您可以在这些 <value-name> 标记中指定任何名称,只要您的安装程序为所有这三个标记创建相应的注册表条目即可。 Google Play 游戏电脑版会使用这些值来启动和卸载游戏。如果您的游戏使用启动器,则 launch-path-registry-location 指定的注册表条目中的值必须指向启动器的目录(而 installation-path-registry-location 必须指向游戏的唯一注册表键,而不是启动器的注册表键)。

        此路径在用户的机器上必须是唯一的。例如:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\YourUniqueName。

        如果您的游戏安装程序是在 64 位 Windows 上运行的 32 位应用,则 Windows 会使用注册表重定向在 HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node 下写入注册表条目。例如,对 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\YourUniqueName 的写入操作会重定向到 HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\YourUniqueName。

      • LAUNCHER_REQUIRES_ELEVATION:指示每次启动时是否需要以管理员身份运行启动器或游戏可执行文件。

        • "true":以管理员身份运行可执行文件。
        • "false":以当前用户身份运行可执行文件。
      • RELATIVE_PATH_TO_LAUNCHER_EXE:安装目录中启动器或游戏可执行文件的路径。必须包含启动器或游戏可执行文件名。例如,如果启动器或游戏文件名为 mygame.exe,且位于 {INSTALL_DIR}\Resources\mygame.exe 下,则必须将 Resources\mygame.exe 填写在此路径中。

      • LAUNCHER_ARGS_IF_ANY:需要传递到启动器或游戏中的任何命令行参数。此条目为可选项。

        • 如果多个参数与一个可执行文件相关联,则需要用空格分隔。
        • 如果可执行文件要求,则参数需要以“--”或“-”开头。
      • UNINSTALLER_REQUIRES_ELEVATION:指明是否需要以管理员身份运行卸载程序可执行文件,才能完成卸载过程。

        • "true":以管理员身份运行可执行文件。
        • "false":以当前用户身份运行可执行文件。

    Play 发布配置文件示例

    假设有一款名为 MyGame 的游戏,其游戏安装程序为 game_installer.exe,游戏启动器为 launcher.exe。该示例还展示了如何使用 CDATA。 play_publishing_config.xml 的示例内容如下:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <play-publishing-config version="1.0">
      <application>
        <!-- The package name for your game. -->
        <package-name>com.mycompany.mygame</package-name>
        <!-- The game's version string. -->
        <version-name>1.0.0</version-name>
      </application>
      <!-- If requiresElevation is "true", installer runs as Administrator
           and a UAC prompt is displayed. This is required for system-wide
           installs (e.g., to Program Files) or writing to HKLM. -->
      <!-- If acceptsCommandLineArguments is "true", the installer must
           be able to accept command-line arguments to enable the auto-play
           feature. -->
      <installer requiresElevation="true" acceptsCommandLineArguments="true">
        <!-- Path to your installer executable. -->
        <path>game_installer.exe</path>
        <!-- The registry location where the installer writes the installation path. -->
        <installation-path-registry-location>
          <!-- Registry key path (typically under HKLM or HKCU).
               game_installer.exe MUST create this key. -->
          <key-name>SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MySystemWideUniqueKey</key-name>
          <!-- game_installer.exe, specified in <path>, creates the registry
               value called 'InstallLocation' within
               SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MySystemWideUniqueKey
               by the time it exits. -->
          <value-name>InstallLocation</value-name>
        </installation-path-registry-location>
      </installer>
    
      <!-- If requiresElevation is "true", launcher runs as Administrator
           and a UAC prompt is displayed on every game launch. -->
      <launcher requiresElevation="true">
        <!-- Specifies the registry location where Google Play Games reads the installation path
             in order to launch the game. -->
        <launch-path-registry-location >
          <!-- Registry key path (typically under HKLM or HKCU) where
               the launch path can be found. -->
          <key-name>SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MySystemWideUniqueKey</key-name>
          <!-- Google Play Games reads the installation directory from this
               registry value, for example InstallLocation, to launch the game. -->
          <value-name>InstallLocation</value-name>
        </launch-path-registry-location>
        <executable-invocation>
          <!-- Game executable or launcher filename, relative to the
               directory path specified in the InstallLocation registry value. -->
          <filename>launcher.exe</filename>
          <!-- Optional arguments to pass to the executable.
               CDATA is used here to avoid issues with special characters
               like & or >. -->
          <arguments><![CDATA[arg1&arg2>arg3]]></arguments>
        </executable-invocation>
      </launcher>
    
      <!-- If requiresElevation is "true", uninstaller runs as
           Administrator and a UAC prompt is displayed for uninstall. -->
      <uninstaller requiresElevation="true">
        <!-- Registry key where Google Play Games finds the
             uninstallation command. -->
        <uninstall-path-registry-location>
          <!-- Registry key path (typically under HKLM or HKCU) where
               uninstall command can be found. -->
          <key-name>SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MySystemWideUniqueKey</key-name>
          <!-- game_installer.exe also creates the registry value, for example, 'UninstallString'
               within SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MySystemWideUniqueKey,
               containing the command Google Play Games executes to uninstall
               the game. -->
          <value-name>UninstallString</value-name>
        </uninstall-path-registry-location>
      </uninstaller>
    </play-publishing-config>
    
  3. 在 Windows 命令行或 Powershell 中运行 Play 发布工具。

    playpublishingtool.exe build-installer-bundle --input=PLAY_PUBLISHING_CONFIG_PATH --output=WAB_OUTPUT_PATH
    

    如需覆盖同名的现有 WAB 文件,请使用 --force 参数。

    playpublishingtool.exe build-installer-bundle --input=PLAY_PUBLISHING_CONFIG_PATH --output=WAB_OUTPUT_PATH --force
    

    替换以下内容:

    • PLAY_PUBLISHING_CONFIG_PATH:Play 发布配置的路径。例如 path\to\play_publishing_config.xml。
    • WAB_OUTPUT_PATH:WAB 文件的路径。 例如 path\to\output_bundle.wab。

    如何使用 Play 发布工具

    假设当前工作目录中有 Play 发布工具二进制文件 playpublishingtool.exe、Play 发布配置 play_publishing_config.xml 和游戏安装程序 game_installer.exe。

    您的当前工作目录应如下所示:

    .\
    ├── game_installer.exe
    ├── play_publishing_config.xml
    ├── playpublishingtool.exe
    

    如需在同一目录中创建名为 installer_bundle.wab 的 WAB,命令如下所示:

    playpublishingtool.exe build-installer-bundle --input=play_publishing_config.xml --output=installer_bundle.wab
    

    使用 --force 参数时,该命令如下所示:

    playpublishingtool.exe build-installer-bundle --input=play_publishing_config.xml --output=installer_bundle.wab --force
    

    成功后,您应该会看到类似如下所示的输出:

    Successfully built the installer bundle at installer_bundle.wab
    

    在以下文件夹中找到 WAB 文件:

      .\
      ├── game_installer.exe
      ├── installer_bundle.wab
      ├── play_publishing_config.xml
      ├── playpublishingtool.exe
    

    在安装 PC 原生游戏时启用自动播放功能(可选)

    Google Play 游戏电脑版支持启用“自动播放”功能,该功能会在安装流程完成后立即自动启动游戏。此功能可让玩家直接进入游戏,并在 Google Play 游戏电脑版生态系统中完成身份验证,从而提供无缝的用户体验。

    运作方式

    启用该功能后,Google Play 游戏电脑版将使用命令行参数向您的第三方 (3P) 安装程序进程传递会话令牌。然后,您的安装程序负责提取此令牌,并使用它在身份验证上下文中启动游戏可执行文件。

    前提条件

    如需使用此功能,您的第三方安装程序必须能够处理命令行参数。

    实施步骤

    1. 在 Play 发布配置中启用自动播放

      如需选择启用此功能,请将 acceptsCommandLineArguments 属性添加到 play_publishing_config.xml 中的 <installer> 元素。

      play_publishing_config.xml 内容摘录示例:

           <installer requiresElevation="true" acceptsCommandLineArguments="true">
              <path>path/to/installer.exe</path>
              <installation-path-registry-location>
                <key-name>SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\key</key-name>
                <value-name>InstallPath</value-name>
              </installation-path-registry-location>
           </installer>
      • 属性:acceptsCommandLineArguments
      • 类型:Boolean
      • 默认值:false
      • 行为:如果您将其设置为 true,GPG 会在执行安装程序时将该会话令牌附加到命令行参数中。
    2. 在安装程序中处理会话令牌

      当 GPG 客户端启动安装程序时,安装程序会收到会话令牌作为命令行参数。

      • 参数格式:--g_session_token=<TOKEN>

      您必须执行的操作:

      • 提取:安装程序必须解析命令行参数,以检索令牌字符串。
      • 传播:如果您的安装流程涉及启动辅助启动器或游戏进程,则安装程序负责将会话令牌安全地传递给使用 SDK 的最终游戏进程。
      • 启动:使用提供的会话令牌启动游戏可执行文件。这样可以确保游戏在经过身份验证的 GPG 环境中运行。否则,InitializeSDK 将失败,玩家需要重启游戏。
    3. 错误处理和后备

      • 令牌检索:如果 GPG 因任何原因(例如令牌生成失败)无法生成或传递会话令牌,安装过程仍会继续。不过,您的安装程序将在没有 --g_session_token 参数的情况下启动。
      • 稳健性:安装程序应能够处理会话令牌缺失的情况。在这种情况下,安装程序应继续进行标准安装;您不应触发自动启动游戏,因为 InitializeSDK 无论如何都会失败。
      • 安装程序错误:您需要负责确保安装程序及其启动的游戏启动序列的稳健性和错误处理。GPG 无法控制安装程序启动后在其中发生的流程。

使用 Play 管理中心发布游戏

为游戏创建 WAB 文件后,请将其上传到 Play 管理中心,并配置其设置和要求。打开 Play 管理中心,选择您的应用,然后按照以下步骤操作:

启用 Windows 原生分发

  1. 在 Play 管理中心内,依次前往测试和发布 > 高级设置 > 外形规格和平台。
  2. 在 Windows 部分中,点击添加 Windows。

配置 PC 要求、商品详情资源,并查看政策

  1. 设置 PC 硬件要求(RAM、GPU 和存储空间),并上传 Google Play 游戏电脑版商品详情资源(屏幕截图和可选视频)。
  2. 返回到测试和发布 > 高级设置 > 外形规格和平台,然后点击同意审核政策,确认符合 Google Play 游戏电脑版质量指南。

在内部测试轨道上测试游戏

  1. 依次前往测试和发布 > 测试 > 内部测试,然后选择 Google Play 游戏电脑版轨道。
  2. 选择最多 100 位测试人员(您可以配置一个与 Android 不同的测试人员名单),上传 Windows App Bundle (.wab),然后点击保存并发布。
  3. 与测试人员分享 Play 管理中心内的选择加入网页链接 (https://play.google.com/apps/internaltest/...) 和客户端深层链接 googleplaygames://deeplink/details?id=PACKAGE_NAME(将 PACKAGE_NAME 替换为应用的软件包名称)。测试人员必须先打开选择加入网页链接,然后点击接受邀请,接着将 googleplaygames://deeplink/details?id=PACKAGE_NAME 粘贴到 Windows 浏览器地址栏中,或点击 Win+R,在 Google Play 游戏电脑版客户端中打开游戏的详情页面,并安装相应 build。

发布到正式版

  1. 依次前往测试和发布 > 正式版,然后选择 Google Play 游戏电脑版轨道。
  2. 选择目标国家/地区(必须与 Android 版的国家/地区定位保持一致,或属于 Android 版的子集)。
  3. 创建新版本或提升内部测试版本,然后提交版本以供审核。审核最多需要 7 天。
  4. 您可以在发布概览页面上使用自管式发布功能,控制已获批准的版本何时发布。