MSIX 封裝工具的最佳做法Best practices for the MSIX Packaging Tool

如果您尚未設定您的環境進行轉換,您可以遵循我們的環境最佳做法建議,然後回到這裡設定 MSIX 封裝工具。If you haven't already configured your environment for conversion, you can follow our environment best practices recommendations and then come back here to set up the MSIX Packaging Tool. 開始進行任何轉換之前,建議您在 MSIX 封裝工具中設定您的設定,以便每次都簡化您的工作流程。Before you start any conversions we recommend configuring your settings in the MSIX Packaging Tool to simplify your workflow each time. 啟動 MSIX 封裝工具,然後移至 [設定] \ (登陸頁面右上方的齒輪)來設定您的工具預設值。Launch the MSIX Packaging Tool and then go to the settings (gear in the top right of the landing page) to configure your tool defaults.

設定您的 MSIX 封裝工具預設值Configure your MSIX Packaging Tool defaults

  • 使用每個套件產生命令列此設定會讓您自動產生命令列範本檔案,如此一來,如果您稍後透過命令列重新封裝相同的應用程式(例如新版本),您可以為該應用程式提供預先設定的命令列範本檔案。Generate a command line with each package This setting will make it so you automatically generate a command line template file so that if you are repackaging the same application (such as a new version) through the command line later, you can have a pre-configured command line template file for that application. 您將需要提供安裝程式,才能在工作流程期間產生範本檔案。You will need to provide an installer in order to generate a template file during the workflow.
  • 針對 [準備電腦] 預設選取 [所有修正]此設定可讓您預先選取所有建議的修正程式,以便在「準備電腦」階段期間,您可以直接選擇停用全部,而不需要個別加以選取。Select all fixes by default for prepare computer This setting allows you to have all of the recommended fixes pre-selected so that during the prepare computer stage, you can simply choose to disable all without having to select them individually.
  • 強制執行 Microsoft Store 版本控制需求如果您打算透過 Microsoft Store 部署應用程式,您應該確定已選取此選項,使其符合存放區需求(這會影響封裝版本需求和最低 OS 版本支援)。Enforce Microsoft Store versioning requirements If you are planning to deploy your application through the Microsoft Store, you should ensure this is selected so that it conforms to the store requirements (this will affect the package version requirements and minimum OS version support). 如果未選取此選項,套件會將最低版本設定為 Windows 10 1709,而且您將可完全控制封裝版本的4個數字。If this option is unchecked, the package will have a minimum version set to Windows 10 1709, and you will have full control over the 4 digits of the package version. 如果勾選此選項,封裝的最低版本會設定為 Windows 10 1809,而版本的結尾必須是. 0 (例如1.5.6.0)。If this option is checked, the package will have a minimum version set to Windows 10 1809 and the version must end in .0 (e.g. 1.5.6.0).
  • 產生封裝時新增封裝完整性如果選取此選項,封裝完整性會自動新增至所有產生的套件。Add Package Integrity when generating a package If this option is selected, Package Integrity will be automatically added to all packages generated. Windows 10 2004 和更新版本支援封裝完整性Package Integrity is supported on Windows 10 2004 and later.
  • 在產生封裝時新增對 MSIX 核心的支援此選項可讓您將MSIX 核心支援新增至您產生的每個套件。Add support for MSIX Core when generating a package This option allows you to add MSIX Core support to every package that you generate. 選取之後,這將會提供一個下拉式清單,讓您指定要支援的 Windows 版本。Once selected, this will offer a dropdown that will allow you to specify the Windows version to support.
  • 預設儲存位置指定將儲存所產生封裝和相關聯檔案的預設儲存位置。Default save location Specify the default save location where the generated packages and associated files will be saved.
  • 預設安裝程式流覽位置指定要用來尋找要轉換之安裝程式的預設位置。Default installer browse location Specify the default location to find installers to convert.
  • 伺服器埠號碼指定 MSIX 封裝工具的伺服器埠號碼。Server port number Specify the server port number for the MSIX Packaging Tool. 如果您打算使用遠端電腦進行轉換,這就是相關的。This is relevant if you are planning to convert using a remote machine.
  • 環境喜好設定指定每個轉換的預設環境。Environment preference Specify the default environment for each conversion.
  • 簽署喜好設定指定要在轉換應用程式時簽署的預設選項。Signing preference Specify the default option for signing when you are converting applications. 必須簽署您的 MSIX 套件才能進行安裝。It is required to sign your MSIX package in order to install it. 您可以從幾個選項中選擇,以進行簽署喜好設定。You can choose from a few options for your signing preference.
    • 以 Device Guard 簽署簽署-如果您的企業中沒有受信任的憑證,我們建議使用此選項。Sign with Device Guard signing - we recommend this option if you don't have a trusted certificate in your enterprise. 在選擇此選項之前,有一些步驟可以啟用您需要採取的Device Guard 簽署There are some steps to enable Device Guard signing that you need to take before choosing this option.
    • 使用憑證簽署(.pfx)-如果您已經有在企業中使用的受信任憑證,我們建議您使用此選項。Sign with a certificate (.pfx) - We recommend this option if you already have a trusted certificate that you are using in your enterprise.
    • 指定 .cer 檔案(不簽署)-如果您不想在轉換時簽署,但想要確保發行者資訊在簽署時是有效的,您可以選擇此選項。Specify a .cer file (does not sign) - If you do not wish to sign at the time of conversion, but want to ensure that the publisher information will be valid at the time of signing you can choose this option.
    • 不要簽署封裝。Do not sign package. -如果您想要使用另一種方法來簽署封裝,或稍後在產生封裝之後,您可以選擇此選項。- If you wish to sign your package using another method or at a later time after the package has been generated you can choose this option. 我們也建議您將時間戳記伺服器 url新增至您的簽署喜好設定(如果適用的話),讓您的應用程式可以安裝,即使您的憑證過期也一樣。We also recommend that you add a timestamp server url to your signing preference (when applicable), so that your application can be installed, even if your certificate expires.

注意

不支援使用 SHA1 憑證簽署 MSIX 套件格式應用程式。Signing an MSIX package format application with a SHA1 certificate is not supported.

其他設定Other Settings

  • File 和 registry 排除專案雖然我們有一組預設的排除專案,但我們建議您針對您的特定需求,查看並新增或移除任何排除專案。File and registry exclusions While we have a default set of exclusion items, we recommend taking a look and adding or removing any exclusion items for your specific needs.
  • 安裝程式結束代碼如果您有想要在轉換期間觸發重新開機的特定安裝程式結束代碼,您可以在這裡指定。Installer exit codes If you have specific installer exit codes that you want to trigger a restart during conversion, you can specify those here. 根據預設,我們已新增通用的公用程式,但如果您不想要觸發重新開機,則可以移除它們。By default we have common ones already added, but you can remove those if you never want restarts to be triggered. 要注意的是,如果您使用的是 UI,封裝工具永遠不會自動觸發重新開機,但如果您使用命令列選項,則會這麼做。To note, a restart will never be triggered automatically by the Packaging Tool if you are using the UI, but it will if you are using the command line option.

您也可以使用這些指示來匯入或匯出您的設定以進行共用。You can also import or export your settings for sharing by using these instructions.

重新封裝期間的最佳做法Best practices during repackaging

當您使用 MSIX 封裝工具時,我們也建議您在重新封裝程式期間做一些最佳作法的事項:When you are using the MSIX Packaging Tool, there are a few things that we also recommend you do as best practice during the repackaging process:

  • 當封裝 ClickOnce 安裝程式時,如果安裝程式未將捷徑傳送到桌面,就必須這麼做。When packaging ClickOnce installers, it is necessary to send a shortcut to desktop if the installer is not doing so already. 一般而言,一律記得針對主要應用程式可執行檔將捷徑傳送到桌面是良好的做法。In general, it is good practice to always remember to send a shortcut to desktop for the main app executable.
  • 建立修改套件時,您需要在工具 UI 中宣告父應用程式的套件名稱 (身分識別名稱),讓工具在修改套件的資訊清單中設定正確的套件相依性。When creating modification packages, you need to declare the package Name (identity name) of the parent application in the tool UI so that the tool sets the correct package dependency in the manifest of the modification package.
  • 執行 [準備電腦] 頁面中的準備步驟是選擇性的,但強烈建議您這麼做,因為這有助於減少封裝中任何多餘的資料。Performing the preparation steps in the Prepare computer page is optional but highly recommended, as this will help reduce any extraneous data in your package.
  • 您必須簽署套件以進行安裝,但我們也建議您將憑證加上時間戳記,以便可以安裝您的應用程式,即使您的憑證過期也一樣。It is required that you sign your package in order to install it, but we also recommend that you timestamp your certificate so that your application can be installed, even if your certificate expires.
  • [封裝資訊] 頁面中的 [宣告安裝位置] 欄位是選擇性的。Declaring an installation location field in the Package information page is optional. 請確定此路徑符合應用程式安裝程式的安裝位置。Make sure that this path matches the installation location of application installer.

測試 MSIX 套件的最佳做法Best practices for testing your MSIX package

我們建議您也在在全新環境進行轉換之後,在環境設定期間所指定的情況下,測試您的 MSIX 套件。We recommend that you also test your MSIX package after conversion on a clean environment, as we specified during environment setup. 您應該在另一部尚未安裝舊版安裝程式的電腦上測試 MSIX 套件,如此您就可以確保部署 MSIX 套件時,它擁有所需的所有元件,而且不會從先前的安裝程式中挑選任何專案。You should test your MSIX package on a different machine that has not installed the previous installer on it, so that you can ensure when you deploy your MSIX package, it has all of the components it needs and it isn't picking anything up from the previous installer. 這可以透過新的虛擬機器(例如快速建立 VM)來達成,或藉由還原轉換電腦(如果您在開始轉換之前建立檢查點)來完成。This can be achieved through a new virtual machine, such as the Quick Create VM, or by reverting your conversion machine if you created a checkpoint before starting conversion.