使用修改套件自訂您的企業應用程式Customize your Enterprise apps with modification packages

自訂應用程式體驗的能力很重要,尤其是針對企業。The ability to customize an application's experience is important, especially for enterprises. 我們向 IT 專業人員說過,我們知道自訂應用程式以符合使用者的需求,對於移至 Windows 10 來說非常重要。We’ve spoken to IT professionals and we know that customizing applications to meet their user's needs is essential to the effort of moving to Windows 10. 自訂使用 MSI 封裝的應用程式時,很容易就能瞭解 IT 專業人員必須從開發人員取得套件,並使用自訂重新封裝安裝程式,以符合其需求。When customizing applications that are packaged using MSI, it is well understood that IT professionals must acquire the package from the developers and re-package the installer with the customization to suit their needs. 這是企業成本高昂的工作。This is a costly effort for enterprises. 接下來,我們想要將自訂和主應用程式分離,以不再需要重新封裝。Moving forward, we want to decouple the customization and the main application so that re-packaging is no longer needed. 這可確保企業從開發人員取得最新的更新,同時仍維持其自訂的控制權。This ensures that enterprises get the latest updates from developers while still maintaining control of their customizations.

在 Windows 10 版本1809中,我們引進了一種新的 MSIX 套件,稱為 修改套件In Windows 10, version 1809, we introduced a new type of MSIX package called a modification package. 修改套件是儲存自訂的 MSIX 封裝。Modification packages are MSIX packages that store customizations. 修改套件也可以是外掛程式/附加元件,這些元件可能沒有啟用點。Modification packages can also be plugins/add-ons that may not have an activation point. IT 專業人員可以使用此功能來彈性地變更 MSIX 容器,讓應用程式依其企業的自訂重迭。IT professionals can use this feature to flexibly change MSIX containers so that applications are overlaid by their enterprise's customizations.

運作方式How it works

修改套件是針對未擁有應用程式程式碼且只有安裝程式的企業所設計。Modification packages are designed for enterprises that do not own the code of the application and only have the installer. 您可以使用 Windows 10 1809 版或更新版本) 的最新版 MSIX 封裝工具 (來建立修改套件。You can create a modification package by using the latest version of the MSIX packaging tool (for Windows 10 version 1809 or later). 如果您有應用程式的程式碼,您也可以建立 應用程式延伸模組。If you have the code for the application, you can alternatively create an app extension.

如果您想要建立對主要應用程式具有嚴格系結的修改套件,可以在修改套件的資訊清單中將主要應用程式宣告為相依性。If you want to create a modification package that has a strict binding to the main app, you can declare the main app as a dependency in the modification package’s manifest.

<Dependencies>
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.15063.0"/>
    <uap4:MainPackageDependency Name="Main.App"/>
</Dependencies>

下列範例示範如何指定不同的憑證或發行者。The following example demonstrates how to specify a different certificate or publisher.

<Dependencies>
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.15063.0"/>
    <uap4:MainPackageDependency Name="Main.App" Publisher="CN=Contoso, C=US" />
</Dependencies>

如果修改套件和主要套件之間的關聯性是一對一的,這就是簡單的設定。This is a simple configuration if the relationship between the modification package and main package is one-to-one. 一般的自訂通常需要 HKEY_CURRENT_USER 或 HKEY_CURRENT_USERCLASS 下的登錄機碼。Typical customizations often require registry keys under HKEY_CURRENT_USER or HKEY_CURRENT_USERCLASS. 在我們的 MSIX 套件中,我們會有使用者的 .dat 和 Userclass .dat 檔案,以抓取登錄機碼。Inside our MSIX package we have User.dat and Userclass.dat files to capture the registry keys. 如果您需要 HKCU\Software 下的登錄機碼,您必須建立使用者 * 的 .dat (就像使用 HKLM\Software *) 。You will need to create User.dat if you need registry keys under HKCU\Software* (just like Registry.dat is used for HKLM\Software*). 如果您需要 HKCU\Sofware\Classes 下的金鑰,請使用 Userclass。 *Use Userclass.dat if you need keys under HKCU\Sofware\Classes*.

以下是建立 .dat 檔案的一般方式:Here are the typical ways to create a .dat file:

  • 使用 Regedit 來建立檔案。Use Regedit to create a file. 在 Regedit 中建立 hive,然後插入必要的金鑰。Create a hive in Regedit and insert the necessary keys. 以滑鼠右鍵按一下 [匯出] 和 [另存新檔]。Than right click, export and save-as hive file. 請務必將檔案命名為 Userclass 或 .datMake sure to name the file either User.dat or Userclass.dat

  • 使用 API 來建立必要的檔案。Use an API to create necessary files. 您可以使用 ORSaveHive 函數來儲存 .dat 檔案。You can use the ORSaveHive function to save a .dat file. 請務必將檔案命名為乙太幣使用者的 .dat 或 Userclass。Make sure to name the file ether User.dat or Userclass.dat

進行必要的變更之後,您可以建立修改套件,就像任何其他 MSIX 封裝一樣。After you’ve made the necessary changes, you can create the modification package like any other MSIX package. 然後,您可以使用目前的部署設定來部署套件。Then you can deploy the package with the current deployment set-up. 當您重新開機主要應用程式時,您可以看到修改套件所做的變更。When you relaunch your main app, you can see the changes that the modification package has made. 如果您選擇移除修改套件,您的主要應用程式將會還原為不含修改套件的狀態。If you choose to remove the modification package, your main app will revert to a state without the modification package.

瞭解裝置上已安裝的修改套件Find out what modification packages are installed on your device

使用 PowerShell 時,您可以使用下列命令來查看已安裝的修改套件。Using PowerShell, you can see installed modification packages using the following command.

Get-AppPackage -PackageTypeFilter Optional

Windows 10 版本1809上的修改套件Modification packages on Windows 10, version 1809

在 Windows 10 版本1809上,修改套件可能包含在登錄中設定所需的設定,因此主要套件將會如預期般執行。On Windows 10, version 1809, modification packages can include configurations needed to be set in the registry such that the main package will run as expected. 這表示您的主要應用程式會利用登錄來查看外掛程式是否存在。Meaning your main application leverages the registry to view whether a plug-in exists. 當您部署主要套件和修改套件時,應用程式會在執行階段上檢視主要套件和修改套件的虛擬登錄 (VREG)。When you deploy the main package and the modification package, at runtime the application will view the virtual registry (VREG) of both the main package and the modification package.

請注意,您的主要套件可能會使用 VREG 來執行下列事項:Note that your main package may be using the VREG to do the following things:

  • 在外掛程式的 DLL) 中,查看載入檔案 (。Viewing where to load the file (the DLL) of the plug-in. 如果是這種情況,請確定檔案是套件的一部分。If this is the case, then ensure that the file is part of the package. 如此一來,主要套件就可以在執行階段上存取檔案。By doing this, main package is able to access the file at runtime.
  • 檢視能看到 VREG 機碼值的位置。Viewing where to see the value of the VREG keys. 您的主要套件可能會尋找存在於 VREG 中的值。Your main package may be looking for a value to exist in the VREG. 當您手動或使用工具來建立修改套件時,請確認該值是否正確。When you create your modification package either by hand or using our tool, ensure that the value is correct.

Windows 10、1903版和更新版本上的修改套件Modification packages on Windows 10, version 1903, and later

Windows 10 1903 版中已加入下列功能。The following features were added to Windows 10, version 1903.

資訊清單更新Manifest update

我們已將下列元素的支援加入 MSIX 修改套件資訊清單。We’ve added support for the following element to the MSIX modification package’s manifest.

<Properties>
   <rescap6:ModificationPackage>true</rescap6:ModificationPackage>
</Properties>

若要確保修改套件能在 1903 版或更新版本中運作,修改套件資訊清單中必須包含此元素。To ensure that modification packages work in version 1903 or later, the modification package's manifest must include this element. 如果您使用 MSIX 封裝工具的 1 月版本來封裝 MSIX 修改套件,則此動作會自動完成。This will be done for you if you package your MSIX modification package using the January release of the MSIX packaging tool. 如果您使用早於該版本的工具來轉換套件,您可以透過在工具中編輯現有套件,來加入這個新的元素。If you've converted a package using our tool prior to the release, you can edit your existing package in our tool to add this new element. 此外,如果使用者安裝修改套件,他們就會看見套件可能會修改主應用程式的警示。In addition, if users install the modification package, they will be alerted that the package may modify the main application.

如果您使用1903版之前建立的修改套件,則必須編輯套件資訊清單,將 MaxVersionTested 屬性更新為10.0.18362.0。If you are using a modification package that was created before version 1903, it is necessary to edit the package manifest to update the MaxVersionTested attribute to 10.0.18362.0.

<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17701.0" MaxVersionTested="10.0.18362.0" />

使用 MSIX 封裝工具建立修改套件Create a modification package using the MSIX Packaging Tool

您可以使用 MSIX 封裝工具建立修改套件:You can create a modification package with the MSIX Packaging Tool:

  • 指定主要套件。Specify the main package. 確定要進行轉換的機器上有 MSIX 版本的主要套件。Be sure to have the MSIX version of your main package available on your machine that you are converting on. 如果沒有,我們會要求您手動提供發行者和主應用程式資訊。If not than we will ask you to manually provide the publisher and main application information. 也有些自訂會要求主應用程式需安裝在您的機器上。Also some customization require that your main application is installed on your machine. 修改套件 MPTModification Package MPT

  • 使用套件編輯器修改經過轉換的套件。Modify the package once it has gone through conversion using the package editor. 主要套件可能會需要修改套件在其 VREG 中具有特定值。There may be a case where the main package requires your modification package to have certain values in their VREG. 您可以移至此處並適當地編輯套件。This is where you would go and edit the package appropriately.

使用 MakeAppx.exe 建立修改套件Create a modification package using MakeAppx.exe

您可以使用 Windows 10 SDK 隨附的 MakeAppX.exe 工具,以手動方式建立修改套件。You can create a modification package manually by using the MakeAppX.exe tool that is included in the Windows 10 SDK.

  • 在資訊清單中,指定主要套件。In the manifest, specify the main package. 包含發行者與主要套件名稱。Include the publisher and the main package name.

    <Dependencies>
      <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17701.0" MaxVersionTested="12.0.0.0"/>
      <uap4:MainPackageDependency Name="HeadTrax" Publisher="CN=Contoso Software, O=Contoso Corporation, C=US" />
    </Dependencies>
    
  • 建立 Registry.dat、User.dat 和 Userclass.dat,無論建立什麼,您都需要登錄機碼來載入您的修改套件。Create Registry.dat, User.dat and Userclass.dat to create whatever registry keys are needed to load your modification package. 這只有在需要主應用程式檢視自訂登錄機碼時才需這麼做。This is only required if you need your main application to view custom registry keys. 請記住,因為所有項目都在容器內執行,因此在執行階段上,主要套件和修改套件的虛擬登錄將會合併,好讓主要套件可以檢視修改套件的虛擬登錄。Remember that since everything is running inside a container, at runtime the main package and the modification package virtual registry will merge such that main package can view the modification packages virtual registry.

此程序也支援檔案系統外掛程式和自訂項目,只要主應用程式可執行檔不在虛擬檔案系統 (VFS) 內即可。This process also supports file system plug-ins and customizations, as long as the executable of the main application is not in a virtual file system (VFS). 這是為了確保主要套件會收到主要套件和修改套件的所有 VFS。This is to ensure that the main package will get all the VFS of the main package and the modification package.