Play 控管型發布

本文說明如何使用 Play 代管安裝功能,在 Google Play 遊戲電腦版發布遊戲。

使用 Play 管理安裝功能時,Google Play 會根據您在 Windows App Bundle (WAB) 檔案中提供的遊戲檔案和中繼資料,管理遊戲的安裝、更新和解除安裝作業。

事前準備

將 Google Play Games SDK 整合至遊戲。如要開始新手上路流程,請傳送電子郵件至 google-play-games-pc@google.com,尋求後續步驟的協助。

將遊戲封裝為 WAB 檔案

如要建立 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 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>
  3. 在 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 原生發行

  1. 在 Play 管理中心,依序前往「測試及發布」>「進階設定」>「板型規格和平台」。
  2. 在「Windows」部分,按一下「新增 Windows」。

設定電腦規格需求、商店資訊素材資源,並詳閱政策

  1. 設定電腦硬體需求 (RAM、GPU 和儲存空間),並上傳 Google Play 遊戲電腦版商店資訊素材資源 (螢幕截圖和選用影片)。
  2. 返回「測試及發布」>「進階設定」>「板型規格和平台」,然後點選「同意審查政策」,確認符合 Google Play 遊戲電腦版品質指南。

透過內部測試群組測試遊戲

  1. 依序前往「測試及發布」>「測試」>「內部測試」,然後選取「Google Play 遊戲電腦版」測試群組。
  2. 選取最多 100 位測試人員 (您可以設定與 Android 不同的測試人員清單)、上傳 Windows App Bundle (.wab),然後按一下「Save and publish」(儲存並發布)。
  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 Games 電腦版用戶端中開啟遊戲詳細資料頁面,並安裝版本。

發布至正式版群組

  1. 依序前往「測試及發布」>「正式版」,然後選取「Google Play 遊戲電腦版」測試群組。
  2. 選取指定國家/地區 (必須與 Android 指定國家/地區相同或包含在其範圍內)。
  3. 建立新版本或將內部測試版本升級,然後提交版本進行審查。審查作業最多需要七天。
  4. 在「發布總覽」頁面使用「控管型發布」功能,控管核准版本的上線時間。