> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Publisher Content 套件

> 說明如何建立及發行 Publisher Content 套件，這是一種讓遊戲發行者能在自己的 CDN 上託管及更新補充內容的套件類型。

# Publisher Content 套件

*Publisher Content* 是一種套件類型，可讓您在自己的內容傳遞網路 (CDN) 上託管補充遊戲內容，同時由平台持續管理安裝、背景下載、完整性驗證及使用者體驗。XBOX One 系列主機支援 Publisher Content 套件，XBOX Series X|S 主機則從 2026 年 10 月 GDK (GDK 2610) 開始支援。

Publisher Content 套件在執行階段的行為與可下載內容 (DLC) 類似：它們會與基礎遊戲一起安裝、掛接到您的處理序中，並在遊戲結束時卸載。與 DLC 不同的是，它們不會透過 Partner Center 擷取、沒有 Store ID，也不會透過 Microsoft Store 銷售或授權。您的服務才是決定發行哪些內容、何時更新以及由誰接收的唯一依據。

## 何時使用 Publisher Content

當您想要執行下列任一項作業時，請考慮使用 Publisher Content：

* 發行小型即時服務更新 (設定資料、調整表、小型資產套件)，而不需經過 Store 擷取流程。
* 提供以發行者品牌為主的附加內容，讓基礎遊戲的所有玩家自動接收。
* 重複使用您已為其他平台上的遊戲所營運的現有 CDN 和內容管線。
* 在 CDN 層級掌控推出時機、區域目標設定或 A/B 測試。

Publisher Content 並非 DLC 的替代品。當您需要個別使用者權利、購買流程或 Microsoft Store 授權時，請繼續使用標準的 [DLC 套件](/zh-TW/build/core-features/common/packaging/packaging-downloadable-content-dlc)。

## 需求與限制

* 每個基礎遊戲只能有一個 Publisher Content 套件。
* 任何擁有基礎遊戲的玩家皆可使用。不會進行個別使用者的授權檢查。
* 支援 XBOX One 系列主機及 XBOX Series X|S 主機。
* 基礎遊戲與 Publisher Content 套件必須使用相同的套件格式。例如，如果基礎遊戲封裝為 MSIXVC2，則 Publisher Content 套件也必須是 MSIXVC2。
* Publisher Content 套件必須很小，亦即大小小於 1 GB。
* Publisher Content 套件會使用發行者提供的簽署資料進行簽署，而基礎遊戲會內嵌對應的公開資料，讓平台能夠驗證聲稱屬於該遊戲的 Publisher Content。基礎遊戲本身的簽署方式與任何其他遊戲相同。簽署資料會因套件格式而異：
  * **XVC 和 MSIXVC** — 原始 CNG 簽署金鑰。必須使用 RSA-4096。
  * **MSIXVC2** — 具有 RSA-4096 金鑰的 X.509 憑證。憑證必須目前有效、具有可存取的 RSA 私密金鑰，並允許數位簽章。

<Info>
  平台不會為 Publisher Content 套件提供內容保密。與 Microsoft Store DLC 不同，Publisher Content 在散發時不會加密：任何從您的 CDN 下載檔案的人都可以檢查其內容。如果您需要對部分承載資料保密，請在封裝之前先在內容本身中加密這些部分。
</Info>

## 各部分如何搭配運作

概括來說：

1. 您在 *MicrosoftGame.config* 中為基礎遊戲宣告**資訊清單 URL**。此 URL 指向您託管在 CDN 上、可隨時更新的小型 JSON 檔案。
2. 您製作一個以 Store ID 參照基礎遊戲的 **Publisher Content 套件**。
3. 您使用發行者簽署資料簽署 Publisher Content 套件。基礎遊戲會內嵌對應的公開資料，讓平台能夠驗證任何聲稱屬於該遊戲的 Publisher Content。
4. 當玩家安裝基礎遊戲時，平台會擷取您的資訊清單、讀取目前 Publisher Content 套件的 CDN URL，並將其安裝排入佇列。
5. 在執行階段，您的遊戲會列舉已安裝的套件，並以掛接 DLC 的相同方式掛接 Publisher Content 套件。

若要發行新版本的內容，請將新套件上傳到您的 CDN，並更新資訊清單使其指向新套件。平台會在下一次檢查更新時取得此變更。

## 設定基礎遊戲

在基礎遊戲的 *MicrosoftGame.config* 檔案中，新增含有 `ManifestUrl` 子元素的 `PublisherContent` 元素。執行您遊戲的每部裝置都必須能連線到此 URL。

```xml theme={null}
<?xml version="1.0" encoding="utf-8"?>
<Game configVersion="1">
    <!-- Existing Identity, ShellVisuals, ExecutableList, StoreId, etc. -->

    <StoreId>9NZTKMP36L8J</StoreId>

    <PublisherContent>
        <ManifestUrl>https://example.com/space-raiders/pubxvc/console/manifest.json</ManifestUrl>
    </PublisherContent>
</Game>
```

如需這些元素的詳細資訊，請參閱 [PublisherContent 元素 (MicrosoftGame.config)](/zh-TW/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-publishercontent) 和 [ManifestUrl 元素 (MicrosoftGame.config)](/zh-TW/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-manifesturl)。

## 製作 Publisher Content 套件

在 Publisher Content 承載資料旁建立 *MicrosoftGame.config*。使用 `PublisherContentBaseProduct` 元素以 Store ID 參照基礎遊戲。

```xml theme={null}
<?xml version="1.0" encoding="utf-8"?>
<Game configVersion="1">
    <Identity Name="ContosoStudios.SpaceRaiders.PublisherContent"
              Publisher="CN=REPLACE_WITH_YOUR_PUBLISHER"
              Version="1.0.0.0"/>

    <ShellVisuals DefaultDisplayName="Space Raiders Publisher Content"
                  PublisherDisplayName="Contoso Studios"
                  StoreLogo="StoreLogo.png"
                  Square150x150Logo="Logo.png"
                  Square44x44Logo="SmallLogo.png"
                  Description="Publisher-hosted content for Space Raiders."
                  BackgroundColor="#000040"
                  SplashScreenImage="SplashScreen.png"/>

    <PublisherContentBaseProduct>9NZTKMP36L8J</PublisherContentBaseProduct>
</Game>
```

如需詳細資訊，請參閱 [PublisherContentBaseProduct 元素 (MicrosoftGame.config)](/zh-TW/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-publishercontentbaseproduct)。

<Note>
  請勿在 Publisher Content 套件中包含 `AllowedProducts` 元素。該元素會將套件識別為標準 DLC，且與 `PublisherContentBaseProduct` 互斥。
</Note>

## 製作資訊清單

在您於基礎遊戲中宣告的 `ManifestUrl` 上託管小型 JSON 資訊清單。資訊清單包含單一 `url` 欄位，指向您 CDN 上目前的 Publisher Content 套件。發佈後請務必不要變更該 url 上的 Publisher Content，而是將每個新的 Publisher Content 套件版本發佈到新的 url，並相應地更新資訊清單。

```json theme={null}
{
    "url": "https://example.com/space-raiders/pubxvc/console/space-raiders-pubxvc-v2.30.1.xvc"
}
```

## 產生發行者簽署資料

發行者簽署資料存放在您的建置電腦上，並在 `makepkg` 封裝基礎遊戲和 Publisher Content 套件時以名稱 (或指紋) 參照。確切形式取決於您的目標套件格式。

<Info>
  請將發行者簽署金鑰或憑證的私密金鑰視為生產環境機密。任何能存取私密資料的人，都可以產生平台會視為來自您的 Publisher Content 套件。
</Info>

### 適用於 XVC 和 MSIXVC 套件

在建置電腦上的 Windows CNG 金鑰儲存提供者中建立 RSA-4096 簽署金鑰。

下列 PowerShell 範例會在 Microsoft Software Key Storage Provider 中建立名為 `MyTestPubXvcSigningKey` 的可匯出 RSA-4096 簽署金鑰。

```powershell theme={null}
Add-Type -AssemblyName System.Security

$keyName = "MyTestPubXvcSigningKey"
$providerName = "Microsoft Software Key Storage Provider"

$cngParams = [System.Security.Cryptography.CngKeyCreationParameters]::new()
$cngParams.Provider     = [System.Security.Cryptography.CngProvider]::new($providerName)
$cngParams.KeyUsage     = [System.Security.Cryptography.CngKeyUsages]::Signing
$cngParams.ExportPolicy = [System.Security.Cryptography.CngExportPolicies]::AllowExport

<# Use an RSA-4096 key. #>
$len = [System.Security.Cryptography.CngProperty]::new(
    "Length", [BitConverter]::GetBytes([int]4096),
    [System.Security.Cryptography.CngPropertyOptions]::None)
$cngParams.Parameters.Add($len)

$key = [System.Security.Cryptography.CngKey]::Create(
    [System.Security.Cryptography.CngAlgorithm]::Rsa, $keyName, $cngParams)

Write-Host "Created CNG key '$keyName' in the $providerName."
```

透過 `/usepublisherkey` 將產生的金鑰名稱傳遞給 `makepkg pack`。如果您使用預設以外的 CNG 金鑰儲存提供者，也請透過 `/publisherkeyprovider` 傳遞其名稱。

### 適用於 MSIXVC2 套件

建立主體金鑰為 RSA-4096 金鑰的 X.509 憑證，並將憑證及其私密金鑰安裝到 `CurrentUser\My` 憑證存放區。

下列 PowerShell 範例會在 `CurrentUser\My` 中建立自我簽署的 RSA-4096 憑證，並匯出其 `.cer` 檔案。

```powershell theme={null}
$subject = "CN=MyTestPubXvcSigningCertificate"
$certificatePath = Join-Path $PWD "MyTestPubXvcSigningCertificate.cer"

$certificate = New-SelfSignedCertificate `
    -Subject $subject `
    -CertStoreLocation "Cert:\CurrentUser\My" `
    -Provider "Microsoft Software Key Storage Provider" `
    -KeyAlgorithm RSA `
    -KeyLength 4096 `
    -HashAlgorithm SHA256 `
    -KeyUsage DigitalSignature `
    -NotAfter (Get-Date).AddYears(5)

Export-Certificate `
    -Cert $certificate `
    -FilePath $certificatePath `
    -Type CERT
```

透過 `/usepublishercert` 將匯出的 `.cer` 路徑或憑證指紋傳遞給 `makepkg pack`。如果憑證安裝在 `My` 以外的存放區，也請透過 `/publishercertstore` 傳遞其名稱。

## 封裝基礎遊戲和 Publisher Content

兩次 `pack` 叫用都必須參照相同的金鑰或憑證。

### 適用於 XVC 和 MSIXVC 套件

封裝基礎遊戲：

```console theme={null}
makepkg pack /f layout.xml /d <base_game_folder> /pd <output_folder> /usepublisherkey <publisherkeyname>
```

封裝 Publisher Content：

```console theme={null}
makepkg pack /f layout.xml /d <publisher_content_folder> /pd <output_folder> /usepublisherkey <publisherkeyname>
```

如果您使用 Microsoft Software Key Storage Provider 以外的 CNG 金鑰儲存提供者，請在兩個命令中都加入 `/publisherkeyprovider <providername>`。

### 適用於 MSIXVC2 套件

封裝基礎遊戲：

```console theme={null}
makepkg pack /msixvc2 /d <base_game_folder> /pd <output_folder> /usepublishercert <thumbprint|certificate.cer>
```

封裝 Publisher Content：

```console theme={null}
makepkg pack /msixvc2 /d <publisher_content_folder> /pd <output_folder> /usepublishercert <thumbprint|certificate.cer>
```

如果憑證安裝在 `CurrentUser\My` 以外的存放區，請在兩個命令中都加入 `/publishercertstore <store>`。

如需詳細資訊，請參閱 [建立套件 (makepkg.exe)](/zh-TW/build/core-features/common/packaging/deployment/makepkg)。

## 發佈與更新

<Note>
  Publisher Content 套件託管在您的 CDN 上，無法上傳到 Partner Center。`makepkg upload` 會拒絕鬆散形式和封裝形式的 Publisher Content 套件。基礎遊戲套件則會透過標準 Partner Center 流程正常上傳。
</Note>

1. 將封裝好的 Publisher Content XVC 上傳到您 CDN 上、資訊清單中所參照的 URL。
2. 將資訊清單 JSON 上傳到您在基礎遊戲 `ManifestUrl` 元素中宣告的 URL。
3. 照常透過 Partner Center 提交並發行基礎遊戲。

若要推出更新：

1. 將新的 Publisher Content 套件上傳到您 CDN 上的新 URL。請勿取代舊的 Publisher Content 套件。
2. 更新資訊清單中的 `url` 值，使其指向新套件。
3. 將更新後的 JSON 檔案上傳到您在基礎遊戲 `ManifestUrl` 元素中宣告的 URL。

已安裝的裝置會在下一次檢查更新時偵測到變更，並在背景下載新的 Publisher Content 套件。

## 在執行階段存取 Publisher Content

在執行階段，請以探索 DLC 的相同方式探索已安裝的 Publisher Content：使用 [XPackageEnumeratePackages](/zh-TW/reference/system/xpackage/functions/xpackageenumeratepackages)，然後使用 [XPackageMountWithUiAsync](/zh-TW/reference/system/xpackage/functions/xpackagemountwithuiasync) 掛接傳回的套件。

傳遞 [XPackageKind::PublisherContent](/zh-TW/reference/system/xpackage/enums/xpackagekind) 可將列舉篩選為僅限 Publisher Content：

```cpp theme={null}
HRESULT hr = XPackageEnumeratePackages(
    XPackageKind::PublisherContent,
    XPackageEnumerationScope::ThisOnly,
    nullptr,
    [](void*, const XPackageDetails* details) -> bool
    {
        // details->packageIdentifier can be passed to XPackageMountWithUiAsync.
        // details->kind is XPackageKind::PublisherContent.
        return true;
    });
```

如果您已從其他來源取得套件識別碼，請使用 [XPackageGetPackageKind](/zh-TW/reference/system/xpackage/functions/xpackagegetpackagekind) 判斷其是否指向 Publisher Content 套件：

```cpp theme={null}
XPackageKind kind;
HRESULT hr = XPackageGetPackageKind(packageIdentifier, &kind);
if (SUCCEEDED(hr) && kind == XPackageKind::PublisherContent)
{
    // Handle Publisher Content.
}
```

由於 Publisher Content 不是透過 Microsoft Store 授權，因此在掛接之前，您不需要呼叫 [XStoreQueryPackageIdByKind](/zh-TW/gdk-docs/docs/reference/system/xstore/xstore_members) 或執行 Store 授權檢查。

## 解除安裝行為

當玩家解除安裝基礎遊戲時，平台會自動解除安裝相關聯的 Publisher Content 套件。您不需要在遊戲程式碼中明確移除它。

## 另請參閱

* [PublisherContent 元素 (MicrosoftGame.config)](/zh-TW/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-publishercontent)
* [ManifestUrl 元素 (MicrosoftGame.config)](/zh-TW/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-manifesturl)
* [PublisherContentBaseProduct 元素 (MicrosoftGame.config)](/zh-TW/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-publishercontentbaseproduct)
* [建立套件 (makepkg.exe)](/zh-TW/build/core-features/common/packaging/deployment/makepkg)
* [XPackageKind](/zh-TW/reference/system/xpackage/enums/xpackagekind)
* [XPackageGetPackageKind](/zh-TW/reference/system/xpackage/functions/xpackagegetpackagekind)
* [XPackageEnumeratePackages](/zh-TW/reference/system/xpackage/functions/xpackageenumeratepackages)
* [GDK 可下載內容 (DLC) 套件](/zh-TW/build/core-features/common/packaging/packaging-downloadable-content-dlc)


## Related topics

- [Publisher Content packages](/build/core-features/common/packaging/packaging-publisher-content.md)
- [Paquetes de Publisher Content](/es/build/core-features/common/packaging/packaging-publisher-content.md)
- [Publisher Content 패키지](/ko/build/core-features/common/packaging/packaging-publisher-content.md)
- [Publisher Content パッケージ](/ja-jp/build/core-features/common/packaging/packaging-publisher-content.md)
- [MicrosoftGame.config Element - PublisherContent](/reference/system/microsoftgameconfig/elements/microsoftgameconfig-element-publishercontent.md)
