一般套件組合應用程式套件Flat bundle app packages

重要

如果您想要提交應用程式至 Microsoft Store,您需要連絡Windows 開發人員支援,以取得使用一般套件組合的核准。If you intend to submit your app to the Store, you need to contact Windows developer support for approval to use flat bundles.

一般套件組合是一種改進應用程式套件檔案的改進方式。Flat bundles are an improved way to bundle your app’s package files. 一般 Windows 應用程式套件組合檔案會使用多層封裝結構,其中應用程式套件檔案必須包含在組合內,而一般組合只會參考應用程式套件檔案來移除這項需求,讓它們可以在應用程式套件組合之外。A typical Windows app bundle file uses a multi-level packaging structure in which the app package files need to be contained within the bundle, flat bundles remove this need by only referencing the app package files, allowing them to be outside of the app bundle. 由於應用程式套件檔案不再包含在套件組合中,因此可以平行處理,這樣會減少上傳時間、更快速的發佈 (,因為每個應用程式套件檔案都可以同時) ,而且最終的開發反復專案會更快速地處理。Since the app package files are no longer contained in the bundle, they can be parallel processed, which results in reduced uploading time, faster publishing (since each app package file can be processed at the same time), and ultimately faster development iterations.

一般套件組合圖表

一般套件組合的另一個優點是建立較少的套件。Another benefit of flat bundles is the need to create less packages. 因為只參考應用程式套件檔案,所以如果封裝未在兩個版本之間變更,則兩個版本的應用程式可以參考相同的套件檔案。Since app package files are only referenced, two versions of the app can reference the same package file if the package did not change across the two versions. 為應用程式的下一個版本建置套件時,這可讓您只建立已變更的應用程式套件。This allows you to have to create only the app packages that have changed when building the packages for the next version of your app. 根據預設,一般套件組合會在與本身相同的資料夾中參考應用程式套件檔案。By default, the flat bundles will reference app package files within the same folder as itself. 不過,這個參考可以變更為其他路徑(相對路徑、網路共用資料夾和 http 位置)。However, this reference can be changed to other paths (relative paths, network shares, and http locations). 若要這樣做,您必須在一般套件組合建立期間直接提供BundleManifestTo do this, you must directly provide a BundleManifest during the flat bundle creation.

如何建立一般套件組合How to create a flat bundle

可透過使用 MakeAppx.exe 工具,或透過使用封裝配置來定義套件組合結構,建立一般套件組合。A flat bundle can be created using the MakeAppx.exe tool, or by using the packaging layout to define the structure of your bundle.

使用 MakeAppx.exeUsing MakeAppx.exe

若要使用 MakeAppx.exe 建立一般套件組合,請像平常一樣使用「MakeAppx.exe 配套」命令,但使用/fb 參數來產生「一般應用程式套件組合」檔案 (這會非常小,因為它只會參考應用程式套件檔案,且不包含任何實際的承載) 。To create a flat bundle using MakeAppx.exe, use the “MakeAppx.exe bundle” command as usual but with the /fb switch to generate the flat app bundle file (which will be extremely small since it only references the app package files and does not contain any actual payloads).

以下是命令語法的範例:Here's an example of the command syntax:

MakeAppx bundle [options] /d <content directory> /fb /p <output flat bundle name>

如需有關使用 MakeAppx.exe 的詳細資訊,請參閱使用 MakeAppx.exe 工具建立應用程式套件For more information on using MakeAppx.exe, see Create an app package with the MakeAppx.exe tool.

使用封裝配置Using packaging layout

或者,您可以使用封裝配置來建立一般套件組合。Alternatively, you can create a flat bundle using the packing layout. 若要這樣做,請將應用程式套件組合資訊清單的PackageFamily元素中的FlatBundle屬性設定為trueTo do this, set the FlatBundle attribute to true in the PackageFamily element of your app bundle manifest. 若要深入了解封裝配置,請查看使用封裝配置的套件建立To learn more about the packaging layout, see Package creation with the packaging layout.

如何部署一般套件組合How to deploy a flat bundle

在可以部署一般套件組合之前,除了應用) 程式套件組合之外,每個應用程式套件 (都必須使用相同的憑證進行簽署。Before a flat bundle can be deployed, each of the app packages (in addition to the app bundle) must be signed with the same certificate. 這是因為所有的應用程式套件檔案 ( .appx/. msix) 現在都是獨立的檔案,而且不再包含在應用程式套件組合內 ( .appxbundle/. msixbundle) 檔。This is because all of the app package files (.appx/.msix) are now independent files and are no longer contained within the app bundle (.appxbundle/.msixbundle) file.

簽署套件之後,您可以透過下列其中一個選項來安裝應用程式:After the packages are signed, you can install the app via one of these options:

  • 按兩下應用程式套件組合檔案,以應用程式安裝程式安裝。Double click the app bundle file to install with App Installer.
  • 使用 PowerShell 中的 add-appxpackage 指令程式,並指向應用程式套件組合檔案 (假設應用程式封裝是應用程式套件組合預期要) 的位置。Use the Add-AppxPackage cmdlet in PowerShell and point to the app bundle file (assuming app packages are where the app bundle expects them to be).

您無法自行部署一般套件組合的個別 .appx/. msix 封裝。You cannot deploy the individual .appx/.msix packages of a flat bundle by themselves. 它們必須透過 .appxbundle/. msixbundle 進行部署。They must be deployed through the .appxbundle/.msixbundle. 不過,您可以在初始安裝後更新一般套件組合的個別 .appx/. msix 封裝。However, you can update individual .appx/.msix packages of a flat bundle after the initial install. 如果您要更新個別的 .appx/. msix 套件,也需要更新一般套件組合的資訊清單。If you do update individual .appx/.msix package, you will also need to update the flat bundle's manifest.

例如,如果您的 v1 一般套件組合是由 msixbundle、x86. msix、msix 和 msix 所組成,且您知道 v2 配套套件組合只有資產套件的變更,則您只需要建立. msixbundle 和資產。 msix 就能安裝更新。For example, if your v1 flat bundle is composed of an .msixbundle, an x86 .msix, an x64 .msix, and an asset .msix, and you know that your v2 bundle only has changes to the asset package, then you only need to build the .msixbundle and the asset .msix to be able to install the update. 您必須建立 v2 的 msixbundle,因為組合會持續追蹤其 msix 封裝的所有版本。You must build the .msixbundle for v2 because the bundle keeps track of all the versions of its .msix packages. 藉由上下加減一點 msix 至 v2 的版本,您需要新的 msixbundle,其中包含這個新的參考。By bumping the version of the asset .msix to v2, you need a new .msixbundle that has this new reference. Msixbundle 可以包含 v1 x86. msix 和 x64. msix 的參考。一般套件組合的 msix 套件不需要有相同的版本號碼。The v2 .msixbundle can contain references to the v1 x86 .msix and x64 .msix; the .msix packages of a flat bundle does not need to have the same version number.