捆绑 MSIX 包Bundle MSIX packages

本文介绍在使用 MSIX 打包工具转换 Windows 安装程序的 x86 和 x64 版本之后,创建捆绑包的过程。This article describes the process of creating a bundle after converting x86 and x64 versions of your Windows installers using the MSIX Packaging Tool.

将安装程序的多个体系结构版本捆绑成一个实体后,只需将该捆绑包上传到 Store 或另一个分发位置。By bundling the multiple architecture versions of your installer into one entity, only the bundle needs to be uploaded to the Store or another distribution location. Windows 10 部署平台可以识别 .msixbundle 包类型,只会下载适用于你设备的体系结构的文件。The Windows 10 deployment platform is aware of the .msixbundle package type and will only download the files that are applicable for your device's architecture. 请记住,如果你决定分发特定应用的 .msixbundle,则再也不能像以前一样只是分发某个 MSIX 包。Keep in mind that if you decide to distribute an .msixbundle for a particular app, you cannot revert back to distributing just an MSIX package.

以下部分提供了生成 .msixbundle 的每个步骤。The following section presents a step-by-step approach to build an .msixbundle. 其中假设已将 Windows 安装程序的现有 x86 和 x64 版本转换为 MSIX 包。It assumes that you have already converted your existing x86 and x64 versions of the Windows installer to MSIX packages.

安装Setup

需要完成以下设置才能成功生成 MSIX 捆绑包:You will need the following setup to successfully build an MSIX bundle:

  • Windows 10 SDK(1809 或更高版本)Windows 10 SDK (version 1809 or above)
  • 已转换的 x64 和 x86 MSIX 包Converted x64 and x86 MSIX packages

步骤1:查找 MakeAppx.exeStep 1: Find MakeAppx.exe

MakeAppx.exe 是 Windows 10 SDK 中提供的一个工具,可用于打包和捆绑 MSIX 包。MakeAppx.exe is a tool available in the Windows 10 SDK that allows for packaging and bundling of MSIX packages. 你将使用此工具将两个 MSIX 包捆绑到一起。You will use this tool to bundle the two MSIX packages together.

MakeAppx.exe 可用于提取 Windows 10 应用包或捆绑包的文件内容。MakeAppx.exe can be used to extract the file contents of a Windows 10 app package or bundle. 它还可以加密和解密应用包与捆绑包。It also encrypts and decrypts app packages and bundles.

安装 Windows 10 SDK 后,通常可在以下位置找到 MakeAppx.exe:After the Windows 10 SDK is installed, MakeAppx.exe is usually found here:

  • [x86] - C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\MakeAppx.exe[x86] - C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\MakeAppx.exe
  • [x64] - C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\MakeAppx.exe[x64] - C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\MakeAppx.exe

步骤2:捆绑包Step 2: Bundle the packages

使用 MakeApp.exe 捆绑包的最简单方法是将要捆绑在一起的所有包添加到一个文件夹中。The easiest way to bundle packages with MakeApp.exe is to add all the packages that you want to bundle together in one folder. 该目录只能包含要捆绑的包,而不能包含其他任何内容。The directory must be free of everything else except the packages that been to be bundled.

将要捆绑的应用包移到一个目录中,如以下屏幕截图所示。Move the app packages that you want to bundle into one directory, as shown in the following screenshot.

在目录中捆绑包

备注

MakeAppx.exe 只会捆绑具有相同标识的包,这意味着,AppID、发布者和版本需要相同。MakeAppx.exe only bundles packages that have the same identity, which means that the AppID, publisher, version needs to be the same. 只有应用程序包的包处理器体系结构可以不同。Only the package processor architecture for an application package can be different.

MakeAppx.exe 使用以下命令行语法。MakeAppx.exe has the following command line syntax.

C:\> "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\MakeAppx.exe" bundle /d input_directorypath 
/p <filepath>.msixbundle

下面是一个示例命令。Here is an example command.

C:\> "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\MakeAppx.exe" bundle /d c:\AppPackages\ 
/p c:\MyLOBApp_10.0.0.0_ph32m9x8skttmg.msixbundle

运行该命令后,将在指定的路径中创建一个未签名的 .msixbundle。After running the command, an unsigned .msixbundle will be created in the path specified. 绑定之前,不需要对包进行签名。Packages do not need to be signed before bundling.

步骤3:为捆绑签名Step 3: Sign the bundle

创建捆绑包后,必须先对包进行签名,然后才能将应用分发给用户或进行安装。After you create the bundle, you must sign the package before you can distribute the app to your users or install it.

若要对包进行签名,需要具有常规代码签名证书并使用 Windows 10 SDK 中的 SignTool.exe。To sign a package, you will need a general code signing certificate and use SignTool.exe from the Windows 10 SDK.

我们强烈建议你使用证书颁发机构提供的受信任证书,因为这样可以使包在最终用户设备上无缝分发和部署。We strongly recommend that you use a trusted cert from certificate authority as that allows for the package to be distributed and deployed on your end users devices seamlessly. 一旦有权访问私有证书(.pfx 文件),就可以对包进行签名,如下所示。Once you have access to the private certificate (.pfx file), you can sign the package as shown below.

备注

SignTool.exe 在 Windows 10 SDK 中 MakeAppx.exe 所在的目录中提供。SignTool.exe is available in the same directory as MakeAppx.exe in the Windows 10 SDK.

SignTool.exe 使用以下命令行语法。SignTool.exe has the following command line syntax.

C:\> "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\SignTool.exe" sign /fd <Hash Algorithm> /a 
/f <Path to Certificate>.pfx /p <Your Password> <File path>.msixbundle

下面是一个示例命令。Here is an example command.

C:\> "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\SignTool.exe" sign /fd SHA256 /a 
/f c:\private-cert.pfx /p aaabbb123 c:\MyLOBApp_10.0.0.0_ph32m9x8skttmg.msixbundle

有关使用 SignTool.exe 为应用包签名的详细信息,请参阅此文For more information about signing app packages with SignTool.exe, see this article.

成功为捆绑包签名后,可将其放在网络共享或任何内容分发网络上,以将其分发给用户。After successfully signing the bundle, you are ready to host it on a network share or on any content distribution network to distribute it to your users.