發布安裝程式

本文說明如何使用遊戲安裝程式,在 Google Play Games 電腦版發布遊戲。

如果採用開發人員安裝流程,您提供的遊戲安裝程式必須管理遊戲的安裝、更新和解除安裝。

事前準備

將 Google Play 遊戲 SDK 整合至遊戲。

將遊戲封裝為 WAB 檔案

Google Play Games 電腦版要求您將遊戲安裝程式上傳至 Google Play 管理中心,做為 Windows App Bundle (WAB) 檔案。如要建立 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 上的遊戲相關聯的專屬 ID。例如: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 和程式碼簽署功能,簽署遊戲的安裝程式執行檔。

      • <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
    

    在電腦原生遊戲安裝後啟用自動播放功能 (選用)

    Google Play Games 電腦版提供「自動玩遊戲」功能,可在安裝完成後立即自動啟動遊戲。這項功能可讓玩家直接進入遊戲,並在 Google Play 遊戲電腦版生態系統中完成驗證,提供流暢的使用者體驗。

    運作方式

    啟用這項功能後,Google Play 遊戲電腦版會使用指令列引數,將工作階段權杖傳遞至第三方安裝程式程序。接著,安裝程式會負責擷取這個權杖,並在經過驗證的環境中,使用權杖啟動遊戲執行檔。

    必要條件

    如要使用這項功能,第三方安裝程式必須能夠處理指令列引數。

    導入步驟

    1. 在 Play 發布設定中啟用自動播放

      如要選擇加入這項功能,請在 play_publishing_config.xml 的 <installer> 元素中加入 acceptsCommandLineArguments 屬性。

      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. 在安裝程式中處理工作階段符記

      Google Play 遊戲用戶端啟動安裝程式時,會收到工作階段符記做為指令列引數。

      • 引數格式:--g_session_token=<TOKEN>

      您必須採取的行動:

      • 擷取:安裝程式必須剖析指令列引數,才能擷取權杖字串。
      • 傳播:如果安裝流程涉及啟動次要啟動器或遊戲程序,安裝程式必須安全地將工作階段符記傳遞至使用 SDK 的最終遊戲程序。
      • 啟動:使用提供的工作階段符記,啟動遊戲執行檔。這可確保遊戲在經過驗證的 GPG 環境中執行。否則 InitializeSDK 會失敗,玩家必須重新啟動遊戲。
    3. 錯誤處理和備用機制

      • 擷取權杖:如果 GPG 因任何原因無法產生或傳遞工作階段符記 (例如權杖產生失敗),安裝程序仍會繼續。不過,安裝程式啟動時不會有 --g_session_token 引數。
      • 穩定性:安裝程式應設計為可處理缺少工作階段符記的情況。在這種情況下,安裝程式應繼續進行標準安裝程序,不應觸發自動啟動遊戲,因為 InitializeSDK 無論如何都會失敗。
      • 安裝程式錯誤:您必須負責確保安裝程式和其啟動的遊戲啟動序列穩定,並處理相關錯誤。GPG 無法控管安裝程式啟動後執行的程序。

透過 Play 管理中心發布遊戲

成功為遊戲建立 WAB 後,請將其上傳至 Play 管理中心,並管理相關設定和規定。請按照下列步驟發布遊戲:

新增 Google Play 遊戲電腦版板型規格

只有在首次發布遊戲時,才需要執行這個步驟。

  1. 在 Play 管理中心的左選單中,依序選取「測試及發布」>「設定」>「進階設定」(直接連結)。
  2. 前往「板型規格」分頁,然後從「+ 新增板型規格」下拉式選單中新增「Google Play Games on PC」。

  3. 按一下右側「Google Play 遊戲電腦版」板型規格對應的「管理」按鈕。

  4. 選取「使用 Windows 應用程式套件遊戲的專屬測試群組」選項。

  5. 依序點選「儲存」和確認對話方塊中的「儲存」。

開啟控管型發布功能

如要開啟控管型發布功能,請按照下列步驟操作。

  1. 在「發布總覽」頁面的「控管型發布」部分,按一下「開啟控管型發布」。
  2. 畫面隨即會顯示對話方塊。將測試群組切換為「開啟控管型發布功能」。
  3. 按一下「儲存」。

上傳 WAB 檔案

如要上傳 WAB 檔案,請按照下列步驟操作:

  1. 在 Play 管理中心的左選單中,依序選取「測試及發布」>「進階設定」(直接連結)。
  2. 在「進階設定」頁面中,按一下「板型規格」分頁標籤。
  3. 在「板型規格」分頁中,按一下「+ 新增板型規格」,然後選取「Google Play 遊戲電腦版」。
  4. 在「Google Play 遊戲電腦版」部分,按一下「管理」。
  5. 選取「使用 Windows 應用程式套件遊戲的專屬測試群組」。
  6. 按一下「儲存」。
  7. 在 Play 管理中心的左選單中,依序選取「測試及發布」>「正式版群組」(直接連結)。
  8. 在「正式版」頁面中,從板型規格下拉式選單選取「僅限 Google Play 遊戲電腦版 (Windows)」。
  9. 在「Windows 應用程式套件」分頁中,按一下「編輯」,然後上傳 WAB 檔案。

設定 Windows 電腦規格需求

如何設定 Windows 電腦規格需求:

  1. 在 Play 管理中心的左選單中,依序選取「開發更多使用者」>「商店發布」>「商店設定」(直接連結)。
  2. 在「PC requirements」(電腦需求) 部分,按一下右側的「Edit」(編輯) 按鈕。
  3. 更新欄位,然後按一下「儲存」。

設定應用程式內購圖片

這個步驟可以省略。如要設定應用程式內購圖片,請按照下列步驟操作:

  1. 在 Play 管理中心的左選單中,依序選取「開發更多使用者」>「商店發布」>「商店資訊」(直接連結)。
  2. 在「商店資訊」分頁的「預設商店資訊」部分,按一下右側的 -> (箭頭) 按鈕。系統隨即會將您導向「預設商店資訊」頁面。
  3. 前往「Google Play 遊戲電腦版」部分,然後在「Google Play 遊戲電腦版 (Windows) 應用程式內購圖片」上傳圖片。
  4. 按一下「儲存」。

將變更送審

  1. 在 Play 管理中心的左選單中,選取「Publishing overview」(發布總覽)。
  2. 在「尚未送審的變更」部分,按一下「將變更送交審查」。

審查團隊核准變更後,您的遊戲就會在 Google Play 上架。