MSIX 應用程式套件的差異更新Differential updates for MSIX app packages

了解 MSIX 應用程式套件更新Understanding MSIX app package updates

建立 MSIX 應用程式套件時,會產生資訊清單檔案,其中包含與 MSIX 應用程式套件中所包含檔案相關的詳細資料。When an MSIX app package are created, a manifest file is generated containing details related to the files included in the MSIX app package. 在建立套件期間,一部分的中繼資料會隨之建立,並且儲存在 .msix 或 .msixbundle 中,允許 Windows 藉此識別出獨有的套件部份。During package creation, a piece of metadata is created and stored in the .msix or .msixbundle package which allows parts of the package to be uniquely identified by the Windows. 稍後在更新期間,Windows 可以使用此中繼資料檔案來比較舊套件與新套件,並決定要下載到裝置的項目。Later on, during update, Windows can use this metadata file to compare the old package to the new package and determine the things that need to be downloaded to the device. 如果此中繼資料可讓套件部分有唯一的身分識別,這表示差異更新機制完全可用在任何套件版本之間 (假設來源套件的版本比目標套件的版本低)。Given this metadata allows parts of the package to be uniquely identified, this means the differential update machinery fully functions from any version of a package to any other version of a package (assuming source package has a lower version than target package).

全都開始於 AppxBlockMap.xml 檔案 (前述的中繼資料)。It all starts at the AppxBlockMap.xml file (the aforementioned metadata). AppxBlockMap.xml 檔案是 XML 文件,其中包含套件中檔案相關資訊的二維清單。The AppxBlockMap.xml file is an XML document that contains a two dimensional list of information about files in the package. 第一個維度輸出檔案的詳細資料概觀 (例如名稱和大小),第二個維度提供該檔案每個 64KB 配量 (也稱為「區塊」) 的 SHA2-256 雜湊表示法。The first dimension lays out high level details on the file (e.g. name and size) and the second dimension provides SHA2-256 hash representations of each 64KB slice of that file (aka the "block").

第一個雜湊代表檔案的第一個 64KB 區塊,而第二個雜湊代表剩餘的 35 KB - 假設檔案為 101188 個位元組。The first hash represents the first 64KB block of the file and the second hash represents the remaining 35KB - given the file is 101188 bytes.

在更新期間,如果修改了該檔案的第二個區塊,則雜湊也會更新以反映此事實。During an update, if the second block of that file was modified, the hash would also be updated to reflect this fact. 下載元件了解此事實,並只會將第二個區塊往下拉,並重複使用舊套件中第一個未變更的區塊。The download component understands this and will only pull down the second block and reuse the first unchanged block from the old package.

此外,如果整個檔案未變更 (這是由一整組未變更的區塊所決定),則可以從現有的套件重複使用該檔案,進而為 Windows 10 使用者節省大量資源Furthermore, if an entire file hasn't changed (which is determined by the full set of blocks not changing) then that file can be reused from the existing package - resulting in tremendous savings for Windows 10 users

升級至更新的版本Upgrading to newer versions

安裝更新版本的 MSIX 應用程式套件時,會比較資訊清單檔案,並識別已修改的檔案區塊。When a newer version of the MSIX app package is installed, the manifest file is compared and modified file blocks are identified. 當 MSIX 應用程式套件升級至更新版本時,若更新的應用程式位於網路共用或組織外部,只擷取已修改的檔案可以降低頻寬耗用量。As the MSIX app package is upgraded to the newer version only the modified files are retrieved decreasing the bandwidth consumption if updated applications reside on a network share or external to an organization.

升級至更舊版本Upgrading to older versions

安裝更舊版本的 MSIX 應用程式套件時,會比較資訊清單檔案,並識別已修改的檔案區塊。When an older version of the MSIX app package is installed, the manifest file is compared and modifed file blocks are identified. 當 MSIX 應用程式套件升級至更舊版本時,若更新的應用程式位於網路共用或組織外部,只擷取已修改的檔案可以降低頻寬耗用量。As the MSIX app package is upgraded to the older version only the modified files are retrieved decreasing the bandwidth consumption if updated applications reside on a network share or external to an organization.

最佳化升級體驗Optimizing upgrade experiences

可以設定將 MSIX 應用程式套件傳遞或安裝至裝置,以改善使用者體驗。The delivery or installation of an MSIX app package to a device can be configured to improve the users experience. 部署應用程式時,可以將裝置設定為在使用者關閉應用程式之後更新應用程式,或強制關閉應用程式並更新應用程式。When an app is deployed the device can be configured to update the app after the user closes the app , or force the application to be closed and update the app forcably.

PowerShellPowerShell

使用 PowerShell 將 MSIX 應用程式套件安裝至裝置,會利用 add-appxpackage Cmdlet。Installing an MSIX app package to a device using PowerShell leverages the add-appxpackage cmdlet. 此 Cmdlet 包含下列參數,其可改變 MSIX 應用程式套件安裝或升級使用者體驗。This cmdlet contains the following parameters which alter the MSIX app package installation or upgrade user experience.

-DeferRegistrationWhenPackagesAreInUse-DeferRegistrationWhenPackagesAreInUse 指出若使用者目前已開啟應用程式,此 Cmdlet 會防止 MSIX 應用程式套件更新。Indicates that this cmdlet will prevent the MSIX app package from updating while the user currently has the app open.
-ForceApplicationShutdown-ForceApplicationShutdown 指出此 Cmdlet 會強制與套件或其相依性相關聯的所有使用中程序關閉Indicates that this cmdlet forces all active processes that are associated with the package or its dependencies to shut down
-ForceUpdateFromAnyVersion-ForceUpdateFromAnyVersion 指出 MSIX 應用程式套件會強制暫存/註冊特定版本的套件,不論是否已暫存/註冊較高的版本。Indicates that the MSIX app package will force a specific version of a package to be staged/registered, regardless of whether a higher version is already stages/registered.
-InstallAllResources-InstallAllResources 指出此 Cmdlet 會強制部署組合引數所指定的所有資源套件。Indicates that the cmdlet forces the deployment of all resource packages specified from a bundle argument. 這會覆寫部署引擎的資源適用性檢查,並強制暫存所有資源套件。This overrides the resource applicability check of the deployment engine and forces staging of all resource packages.
-RetainFilesOnFailure-RetainFilesOnFailure 在部署失敗的情況下,如果此參數設為 True,則不會移除安裝過程中已在目標電腦上建立的檔案。In the case of a failed deployment, if this switch is set to True, files that have been created on the target machine during the installation process are not removed.
-Update-Update 指定要新增的套件是相依性套件更新。Specifies that the package being added is a dependency package update. 移除父應用程式時,會移除相依性套件。A dependency package is removed when the parent app is removed. 如果未指定,則移除父應用程式時不會移除套件。If not specified, the package will not be removed when the parent app is removed.

如需此 Cmdlet 可用的參數完整清單,請造訪 add-appxpackage上的 PowerShell 文章。For a full list of parameters available for this cmdlet, please visit the PowerShell article on add-appxpackage.