本文档介绍了如何使用游戏安装程序在 Google Play 游戏电脑版平台上发布游戏。
在开发者安装流程中,您提供的游戏安装程序必须管理游戏的安装、更新和卸载。
准备工作
将 Google Play 游戏 SDK 集成到游戏中。
将游戏打包为 WAB 文件
Google Play 游戏电脑版要求将游戏安装程序作为 Windows app bundle (WAB) 文件上传到 Google Play 管理中心。如需创建 WAB 文件,请按以下步骤操作:
下载 Play 发布工具。 您可以在 Windows 命令行或 PowerShell 中运行此工具。
创建 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 中安装程序文件的路径。此路径可以是绝对路径,也可以是相对于 Play 发布配置父目录的相对路径。例如,path\to\test\installer。 请务必使用 Authenticode 和代码签名为游戏的安装程序可执行文件签名。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 游戏电脑版会在多个配置单元下搜索此路径,以找到启动和卸载所需的值。在
此路径在用户机器上必须是唯一的。例如:INSTALLER_PATH中指定的可执行文件必须创建这些注册表项。在安装完成之前,必须创建在installation-path-registry-location、launch-path-registry-location和uninstall-path-registry-location下指定的这些注册表项和值名称对。虽然该示例使用了InstallLocation和UninstallString,但您可以在这些<value-name>标记中指定任何名称,前提是您的安装程序为这三个标记创建相应的注册表条目。 Google Play 游戏电脑版使用这些值来启动和卸载游戏。如果您的游戏使用启动器,则此路径必须指向包含启动器安装信息的注册表项,并且由launch-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>在 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) 安装程序进程传递会话令牌。然后,您的安装程序负责提取此令牌,并使用它在经过身份验证的上下文中启动游戏可执行文件。
前提条件
如需使用此功能,您的 3P 安装程序必须能够处理命令行参数。
实施步骤
在 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 会在执行安装程序时将会话令牌附加到命令行参数。
- 属性:
在安装程序中处理会话令牌
当 GPG 客户端启动安装程序时,它将收到会话令牌作为命令行参数。
- 参数格式:
--g_session_token=<TOKEN>
您必须执行的操作:
- 提取:您的安装程序必须解析命令行参数以检索令牌字符串。
- 传播:如果您的安装流程涉及启动辅助启动器或游戏进程,则您的安装程序负责将会话令牌安全地传递给使用 SDK 的最终游戏进程。
- 启动:使用提供的会话令牌启动游戏可执行文件。这可确保游戏在经过身份验证的 GPG 上下文中运行。否则,InitializeSDK 将失败,玩家需要重启游戏。
- 参数格式:
错误处理和回退
- 令牌检索:如果 GPG 因任何原因无法生成或传递会话令牌(例如,令牌生成失败),安装过程仍将继续。但是,您的安装程序将在没有
--g_session_token参数的情况下启动。 - 稳健性:您的安装程序应设计为处理会话令牌缺失的情况。在这种情况下,安装程序应继续执行标准安装;您不应触发自动游戏启动,因为 InitializeSDK 无论如何都会失败。
- 安装程序错误:您负责安装程序的稳健性和错误处理,以及它启动的游戏启动序列。GPG 无法控制安装程序启动后在其中发生的进程。
- 令牌检索:如果 GPG 因任何原因无法生成或传递会话令牌(例如,令牌生成失败),安装过程仍将继续。但是,您的安装程序将在没有
使用 Play 管理中心发布游戏
成功为游戏创建 WAB 后,将其上传到 Play 管理中心并管理其设置和要求。按照以下步骤发布游戏:
添加“Google Play 游戏电脑版”设备规格
此步骤仅在您首次发布游戏时是必需的。
- 在 Play 管理中心的左侧菜单中,依次选择测试和 发布 > 设置 > 高级设置 (直接链接)。
前往设备规格标签页,然后从 + 添加设备规格下拉菜单中添加
Google Play Games on PC。点击右侧与 Google Play 游戏电脑版 设备规格对应的管理 按钮。
选择为您的 Windows app bundle 游戏使用专用轨道 选项。
点击保存 ,然后在确认对话框中再次点击保存 。
开启自管式发布模式
如需开启自管式发布模式,请按以下步骤操作。
- 在发布概览 页面上的自管式发布 部分中,点击开启自管式发布模式 。
- 此时会出现一个对话框。将轨道的自管式发布模式 切换为开启 。
- 点击保存。
上传 WAB 文件
如需上传 WAB 文件,请按以下步骤操作:
- 在 Play 管理中心的左侧菜单中,依次选择 测试和发布 > 设置 > 高级设置(直接链接)。
- 在高级设置页面中,点击设备规格标签页。
- 在设备规格标签页中,点击 + 添加设备规格,然后选择 Google Play 游戏电脑版进行添加。
- 在 Google Play 游戏电脑版部分,点击管理。
- 选择为您的 Windows app bundle 游戏使用专用轨道 。
- 点击保存。
- 在 Play 管理中心的左侧菜单中,依次选择 测试和发布 > 正式版 (直接链接)。
- 在正式版 页面中,从设备规格下拉菜单中选择仅限 Google Play 游戏电脑版 (Windows) 。
- 在 Windows app bundle 标签页中,点击修改 ,然后上传 WAB 文件。
配置 Windows PC 要求
如需配置 Windows PC 要求,请执行以下操作:
- 在 Play 管理中心的左侧菜单中,依次选择 拓展用户 > 商店发布 > 商店设置 (直接链接)。
- 在 PC 要求 部分中,点击右侧的修改 按钮。
- 更新字段,然后点击保存 。
配置应用内购图片
这是一个可选步骤。如需配置应用内购图片,请执行以下操作:
- 在 Play 管理中心的左侧菜单中,依次选择 拓展用户 > 商店发布 > 商品详情(直接链接)。
- 在商品详情 标签页的默认商品详情 部分中,点击右侧的 -> (箭头)按钮。系统会将您转到默认商品详情 页面。
- 前往 Google Play 游戏电脑版部分,然后在 Google Play 游戏电脑版 (Windows) 应用内购买图片中上传图片。
- 点击保存。
将更改内容送审
- 在 Play 管理中心的左侧菜单中,选择发布概览 。
- 在更改内容尚未送审部分中,点击将更改内容送审。
当审核团队批准您的更改后,用户便可在 Google Play 上发现您的游戏。