本文說明如何使用 Play 代管安裝功能,在 Google Play 遊戲電腦版發布遊戲。
使用 Play 管理安裝功能時,Google Play 會根據您在 Windows App Bundle (WAB) 檔案中提供的遊戲檔案和中繼資料,管理遊戲的安裝、更新和解除安裝作業。
事前準備
將 Google Play Games SDK 整合至遊戲。如要開始新手上路流程,請傳送電子郵件至 google-play-games-pc@google.com,尋求後續步驟的協助。
將遊戲封裝為 WAB 檔案
如要建立 Play 受管理安裝 WAB 檔案,請按照下列步驟操作:
下載 Play 發布工具。您可以在 Windows 指令列或 PowerShell 執行這項工具。
建立 Play 發布設定檔,並任意命名。例如,
play_publishing_config.xml採用以下格式:<?xml version="1.0" encoding="UTF-8"?> <play-publishing-config version="1.0"> <!-- Application metadata: This section contains basic information about your game. --> <application> <package-name>PACKAGE_NAME</package-name> <version-name>VERSION_NAME</version-name> </application> <!-- Game files: This section specifies which game files to include in the bundle and how to treat them. --> <game-files> <file-set> <root-folder-path>PATH_TO_ROOT_FOLDER</root-folder-path> <!-- absolute or relative to the parent directory of the config xml --> <!-- Exclusions: A list of files or folders to exclude from the bundle. This is useful for removing development files, temporary data, or redundant assets. --> <exclusions> <file-path>REGEX_PATTERN_OF_EXCLUDED_FILES</file-path> <file-path>PATH_TO_BE_EXCLUDED</file-path> </exclusions> <!-- File attributes: Define special handling for certain files during installation and updates. --> <file-attribute value=FILE_ATTRIBUTE_VALUE> <file-path>PATH_TO_FILE</file-path> <file-path>REGEX_PATTERN_OF_FILE_ATTRIBUTE_FILES</file-path> </file-attribute> </file-set> </game-files> <!-- This file represents the startup process for this game. Google Play Games for PC should start this process when user clicks on "Play" on this game. --> <launch-command> <path>PATH_TO_LAUNCH_FILE</path> <arguments>ARGUMENTS</arguments> </launch-command> <!-- Lifecycle operations: Custom actions to be performed during the game's installation and uninstallation. --> <lifecycle-operations> <!-- Install operations: These actions run when the game is installed. 'requiresElevation="true"' will trigger a UAC prompt for administrator rights. There are three types of install operations that can be specified. An instance of each is listed below. --> <install-operation requiresElevation=INSTALL_OPERATION_REQUIRES_ELEVATION> <operation-identifier>OPERATION_IDENTIFIER_STRING</operation-identifier> <execute-file> <path>PATH_TO_INSTALL_EXECUTE_FILE</path> <arguments>ARGUMENTS</arguments> </execute-file> </install-operation> <install-operation requiresElevation=INSTALL_OPERATION_REQUIRES_ELEVATION> <operation-identifier>OPERATION_IDENTIFIER_STRING</operation-identifier> <update-registry baseKey=BASE_KEY> <sub-key>SUB_KEY_PATH</sub-key> <value-name>VALUE_NAME</value-name> <value type=REGISTRY_VALUE_TYPE>VALUE_TEXT</value> </update-registry> </install-operation> <!-- Uninstall operations: These actions run before the game is uninstalled. --> <uninstall-operation requiresElevation=UNINSTALL_OPERATION_REQUIRES_ELEVATION> <execute-file> <path>PATH_TO_UNINSTALL_EXECUTE_FILE</path> <arguments>ARGUMENTS</arguments> </execute-file> </uninstall-operation> </lifecycle-operations> </play-publishing-config>
替換下列內容:
PACKAGE_NAME:遊戲的套件名稱。這是與 Google Play 上的遊戲相關聯的專屬 ID。例如:com.yourcompany.yourgame。套件名稱必須遵循下列規則:- 必須包含至少兩個區隔 (一或多個點)。
- 每個區隔的開頭都必須是英文字母。
- 所有字元都必須為英數字元或底線 (
[a-zA-Z0-9_])。
VERSION_NAME:遊戲的版本字串。這可以是任意字串,但遊戲中所有上傳的 WAB 都必須使用不重複的字串。例如:1.0、1.0.1-beta、2025.11.24、v1.rc1。PATH_TO_ROOT_FOLDER:遊戲檔案所在根資料夾的路徑。除了排除項目中提及的檔案外,這個資料夾中的所有檔案都會新增至套件。這個路徑可以是「絕對」路徑,也可以是相對於包含play_publishing_config.xml檔案的目錄的「相對」路徑。exclusions:(選用) 指定PATH_TO_ROOT_FOLDER內檔案的路徑或模式,以便從套件中排除。您可以在exclusions元素中加入多個file-path元素。路徑可以透過下列兩種方式表示:- 檔案路徑:要排除的檔案路徑。
- 規則運算式字串:凡是與規則運算式字串相符的檔案,都會從套件中排除。請使用 RE2 語法。
file-attribute:(選用) 定義特定檔案或符合規則運算式模式的檔案屬性。FILE_ATTRIBUTE_VALUE:可以是下列其中一項:SKIP_UPDATE:更新期間,這項屬性會指示系統僅在檔案不存在時複製檔案,並保留對現有檔案所做的任何變更。MODIFIED_ON_DEVICE:如果檔案必須更新,但安裝後可能會在裝置上修改,請使用這個選項。更新時,系統會下載完整的新檔案,並覆寫已安裝的版本。在安裝完整性檢查期間,如果這個檔案與安裝的版本不同,系統不會將安裝視為損毀。
file-path:識別這項屬性的檔案。每個file-attribute元素中可包含多個file-path元素。每條路徑都可以透過下列兩種方式之一表示:- 檔案路徑:要與這項屬性建立關聯的檔案路徑。
- 規則運算式字串:與規則運算式字串相符的所有檔案,都會與屬性值建立關聯。請使用 RE2 語法。
PATH_TO_LAUNCH_FILE:用於啟動遊戲的可執行檔案路徑。ARGUMENTS:(選用) 指令列引數。<arguments>元素用於將引數傳遞至<launch-command>、<install-operation>或<uninstall-operation>中指定的可執行的檔案。每次使用<arguments>元素時,都只會套用至與其一起定義的可執行檔,因此您可以為不同的可執行檔指定不同的引數。- 如果可執行檔有多個引數,請以空格分隔。
- 如果執行檔需要,請在引數前面加上
--或-。範例:<arguments>--package_name --version_name</arguments>
lifecycle-operations:(選用) 安裝或解除安裝遊戲時執行的自訂動作。install-operation:安裝遊戲時要執行的動作。您可以指定兩種安裝作業:execute-file和update-registry。uninstall-operation:解除安裝遊戲前要執行的動作。解除安裝期間,系統會自動還原update-registry作業。INSTALL_OPERATION_REQUIRES_ELEVATION:指出安裝作業是否需要以管理員權限執行。- "true":以管理員身分執行。
- "false":以目前使用者的身分執行。如未指定,則預設為這個值。
UNINSTALL_OPERATION_REQUIRES_ELEVATION:指出解除安裝作業是否需要以管理員權限執行。- "true":以管理員身分執行。
- "false":以目前使用者的身分執行。如未指定,則預設為這個值。
operation-identifier:用來識別install-operation的專屬字串。execute-file:執行可執行的檔案。PATH_TO_INSTALL_EXECUTE_FILE:安裝期間要執行的可執行檔路徑。PATH_TO_UNINSTALL_EXECUTE_FILE:解除安裝前要執行的可執行檔路徑。
update-registry::建立或更新 Windows 登錄項目。BASE_KEY:定義要在 Windows 登錄中使用的根金鑰。可接受的值:HKEY_CLASSES_ROOT、HKEY_CURRENT_CONFIG、HKEY_CURRENT_USER、HKEY_LOCAL_MACHINE、HKEY_PERFORMANCE_DATA和HKEY_USERS。執行update-registry作業時,請根據使用的baseKey,在父項install-operation上設定requiresElevation="true":HKEY_LOCAL_MACHINE或HKEY_CURRENT_CONFIG:設定requiresElevation="true"。HKEY_CURRENT_USER: 不需要requiresElevation="true"。HKEY_CLASSES_ROOT:只有在寫入全機區段時,才需要設定requiresElevation="true";使用者專屬區段則不需要。HKEY_USERS:包含所有使用者的設定檔。修改目前使用者以外的設定檔 (例如其他使用者或.DEFAULT) 時,請設定requiresElevation="true"。
SUB_KEY_PATH:代表 Windows 登錄檔中特定機碼的路徑,巢狀結構位於主要baseKey下方。VALUE_NAME:指定要在指定子機碼中修改的資料項目名稱。REGISTRY_VALUE_TYPE:這項屬性指定寫入登錄檔的值資料類型。支援的值為STRING(字串) 或DWORD(32 位元數字)。VALUE_TEXT:要儲存在登錄機碼中的資料。
如何使用規則運算式
您可以在
file-path標記中使用 RE2 語法規則運算式,將排除項目或檔案屬性套用至一組檔案。請記得使用正斜線/做為目錄分隔符號,並使用反斜線\逸出特殊規則運算式字元。例如,使用\.比對常值點.,或使用\d比對數字。常見的情形有:
- 比對任何目錄中具有特定副檔名 (例如 .log) 的所有檔案
使用
.*\.log比對任何以.log結尾的路徑,例如game.log或logs/errors.log。<file-path>.*\.log</file-path>
- 比對特定資料夾 (例如「temp」) 中的所有檔案和子目錄
使用
temp/.*比對所有開頭為temp/的路徑,例如temp/data.txt或temp/saves/file.sav。<file-path>temp/.*</file-path>
- 比對特定資料夾中符合模式的檔案
使用
assets/level\d\.dat比對assets/level1.dat、assets/level2.dat,但不比對assets/other.dat。<file-path>assets/level\d\.dat</file-path>
- 比對路徑中任何位置出現的資料夾名稱
使用
.*/cache/.*比對任何名為cache的目錄下的檔案,例如game/cache/file.txt或temp/cache/other.log。<file-path>.*/cache/.*</file-path>
- 比對副檔名為其中一種的檔案 (例如 .ini、.cfg、.sav)
使用
.*\.(ini|cfg|sav)比對任何結尾為.ini、.cfg或.sav的檔案,例如settings.ini、config.cfg或saves/slot1.sav。<file-path>.*\.(ini|cfg|sav)</file-path>
- 比對特定目錄中具有特定副檔名的檔案 (例如 music/ 或 sfx/ 中的 .ogg)
使用
(music|sfx)/.*\.ogg比對位於music/或sfx/目錄下的任何.ogg檔案,但不得位於其他位置。與music/level1.ogg或sfx/explosion.ogg相符,但不符合voice/intro.ogg。<file-path>(music|sfx)/.*\.ogg</file-path>
Play 發布設定檔範例
以下是名為
TestGame的遊戲play_publishing_config.xml範例:<?xml version="1.0" encoding="UTF-8"?> <play-publishing-config version="1.0"> <application> <package-name>com.test.package</package-name> <version-name>1.0</version-name> </application> <game-files> <file-set> <root-folder-path>C:\Users\Username\game-files</root-folder-path> <exclusions> <file-path>mock_game\d\.exe</file-path> <!-- exclude files using a regex --> <file-path>deprecated_graphics</file-path> <!-- exclude a folder --> <file-path>.*\.log</file-path> <!-- recursively exclude all files with .log extension --> </exclusions> <file-attribute value="SKIP_UPDATE"> <file-path>settings.ini</file-path> </file-attribute> <file-attribute value="MODIFIED_ON_DEVICE"> <file-path>game_assets\d\.zip</file-path> <!-- define the path using regex --> </file-attribute> </file-set> </game-files> <launch-command> <path>launcher_test_game.exe</path> <arguments>--launch-arg</arguments> <!-- optional --> </launch-command> <lifecycle-operations> <install-operation requiresElevation="true"> <operation-identifier>elevated-execute-file</operation-identifier> <execute-file> <path>install_file.exe</path> <arguments>--arg</arguments> <!-- optional --> </execute-file> </install-operation> <install-operation requiresElevation="true"> <operation-identifier>elevated-update-registry</operation-identifier> <update-registry baseKey="HKEY_LOCAL_MACHINE"> <sub-key>SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TestGame</sub-key> <value-name>InstallLocation</value-name> <value type="STRING">C:\Program Files\TestGame</value> </update-registry> </install-operation> <uninstall-operation requiresElevation="true"> <execute-file> <path>uninstall.exe</path> <arguments>--test-arg</arguments> <!-- optional --> </execute-file> </uninstall-operation> </lifecycle-operations> </play-publishing-config>
在 Windows 指令列或 PowerShell 中,使用
build-bundle指令執行 Play 發布工具:playpublishingtool.exe build-bundle --input=PLAY_PUBLISHING_CONFIG_PATH --output=WAB_OUTPUT_PATH
如要覆寫名稱相同的現有 WAB 檔案,請使用
--force引數。playpublishingtool.exe build-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 發布工具
如果目前使用的目錄中,
game_files/包含playpublishingtool.exe、play_publishing_config.xml和遊戲檔案:.\ ├── game_files/ ├── play_publishing_config.xml ├── playpublishingtool.exe
如要在同一個目錄中建立
pmi_bundle.wab,請執行:playpublishingtool.exe build-bundle --input=play_publishing_config.xml --output=pmi_bundle.wab
工具建構套件時,終端機會顯示進度列:
Building bundle: [==== ] 40%
成功後,輸出結果應該會類似下方:
Building bundle: [===========] 100% Successfully built the managed install bundle at pmi_bundle.wab
在資料夾中找出 WAB 檔案:
.\ ├── game_files/ ├── pmi_bundle.wab ├── play_publishing_config.xml ├── playpublishingtool.exe
透過 Play 管理中心發布遊戲
為遊戲建立 WAB 檔案後,請將檔案上傳至 Play 管理中心,並設定相關設定和需求。開啟 Play 管理中心,選取應用程式,然後按照下列步驟操作:
啟用 Windows 原生發行
- 在 Play 管理中心,依序前往「測試及發布」>「進階設定」>「板型規格和平台」。
- 在「Windows」部分,按一下「新增 Windows」。
設定電腦規格需求、商店資訊素材資源,並詳閱政策
- 設定電腦硬體需求 (RAM、GPU 和儲存空間),並上傳 Google Play 遊戲電腦版商店資訊素材資源 (螢幕截圖和選用影片)。
- 返回「測試及發布」>「進階設定」>「板型規格和平台」,然後點選「同意審查政策」,確認符合 Google Play 遊戲電腦版品質指南。
透過內部測試群組測試遊戲
- 依序前往「測試及發布」>「測試」>「內部測試」,然後選取「Google Play 遊戲電腦版」測試群組。
- 選取最多 100 位測試人員 (您可以設定與 Android 不同的測試人員清單)、上傳 Windows App Bundle (
.wab),然後按一下「Save and publish」(儲存並發布)。 - 請將 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 Games 電腦版用戶端中開啟遊戲詳細資料頁面,並安裝版本。
發布至正式版群組
- 依序前往「測試及發布」>「正式版」,然後選取「Google Play 遊戲電腦版」測試群組。
- 選取指定國家/地區 (必須與 Android 指定國家/地區相同或包含在其範圍內)。
- 建立新版本或將內部測試版本升級,然後提交版本進行審查。審查作業最多需要七天。
- 在「發布總覽」頁面使用「控管型發布」功能,控管核准版本的上線時間。