适用于 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 来部署应用程序,则应确保选中此选项,使其符合应用商店要求(这将影响包版本要求和最低操作系统版本支持)。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 Core 的支持此选项允许你将.Msix Core支持添加到生成的每个包。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. 在选择此选项之前,需要执行一些步骤来启用设备保护签名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 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.