MSIX 打包扩展MSIX Packaging Extension

MSIX 打包扩展是一种 Azure DevOps 扩展,可帮助使用 MSIX 包格式生成、打包和签名 Windows 应用。The MSIX Packaging Extension is an Azure DevOps extension which helps build, package and sign Windows apps using the MSIX package format.

CI/CD 工作流已成为开发过程中必不可少的一部分,可提高效率和质量,同时降低成本和缩短上市时间。CI/CD workflows have become an integral part of the development process to improve efficiency and quality while reducing cost and time to market. Microsoft 的 CI/CD 解决方案 Azure DevOps 管道已广泛采用且很受欢迎,但使用 YAML 文件将需要打包为 MSIX 的应用的生成和部署工作流集成到 Azure Pipelines 则是一件枯燥的工作,尤其是对于不是 Azure Pipelines 或 MSIX 专家的用户来说。Microsoft's CI/CD solution Azure DevOps Pipelines is widely adopted and popular, but the current process of integrating build and deployment workflows for apps that need to be packaged as MSIX into Azure Pipelines by using YAML files is tedious, specifically for people that are not Azure Pipelines or MSIX experts. 此 Azure DevOps 扩展提供了一个简单、直观且基于 UI 的解决方案,使你可以更轻松地自动执行打包为 MSIX 的应用的生成和部署过程,并使具有现有 CI/CD 工作流的应用可以移动到 MSIX,而不会中断其生成和部署机制。This Azure DevOps extension offers a straightforward, intuitive and UI based solution making it easier to automate build and deployment process for apps being packaged as MSIX, and for apps with existing CI/CD workflows to move to MSIX without disrupting their build and deployment mechanisms.

MSIX 打包扩展包含以下任务,可根据要求用于自定义生成管道:The MSIX Packaging Extension contains the following tasks that you can use to custom build your pipeline according to your requirements:

  1. MSIX 生成和打包 - 使用 MSIX 包格式生成和打包 Windows 应用MSIX build and package - to build and package Windows apps using the MSIX package format
  2. MSIX 包签名 - 使用受信任的证书对 MSIX 包进行签名MSIX package signing - to sign MSIX packages using a trusted certificate
  3. MSIX 的应用安装程序文件 - 为 MSIX 应用创建或更新 .appinstaller 文件App installer file for MSIX - to create or update a .appinstaller file for MSIX apps
  4. 为 MSIX 应用附加创建包 - 为 MSIX 应用附加创建 VHDX 包Create package for MSIX app attach - to create a VHDX package for MSIX app attach

安装扩展Install the extension

浏览 Azure DevOps 商城,并查找名为 MSIX 打包扩展的扩展。Browse the Azure DevOps Marketplace and look for the extension name MSIX Packaging Extension.

浏览商城

创建管道Create a Pipeline

创建 Azure DevOps 项目的新管道。Create a new pipeline for your Azure DevOps project.

选择管道

新建管道

将该选项选择为“使用经典编辑器创建无 YAML 的管道”。Select the option to Use the classic editor to create a pipeline without YAML.

使用经典编辑器

选择版本控制系统,并提供存储库和默认分支的详细信息。Select your version control system and provide your repository and default branch details.

配置源版本控制系统

当要求选择模板时,单击“从空作业开始”。When asked to Select a template, click *start with an Empty job _.

从空作业开始

将“代理规范”选择更改为 “windows-2019”,因为 MSIX 扩展仅在 Windows 代理上运行。Change your Agent Specification* selection to *windows-2019 since the MSIX extension runs only on a Windows agent.

代理规范窗口

默认情况下,你可在管道中看到“代理作业 1”。You should see _Agent job 1* by default in your pipeline. 单击加号符号以向代理作业 1 添加任务。Click on the plus symbol to Add a task to Agent job 1.

在“添加任务”搜索栏中搜索”MSIX”,你可在 MSIX 打包扩展中看到之前提到的任务。Search for MSIX _ in the _Add tasks search bar and you should see the tasks mentioned before in the MSIX Packaging Extension. 可根据要求添加所需的任务以自定义生成管道。You can custom build your pipeline by adding the tasks you need according to your requirements. 但我们将演示如何在此页上配置所有四项任务。But we will demonstrate how to configure all four tasks on this page.

添加任务

MSIX 生成和打包MSIX build and package

生成和打包任务

  • 显示名称 - 自定义任务名称Display name - Customize your task name
  • 输出路径 - 指定将由此任务创建的 MSIX 包的输出路径。Output Path - Specify the output path for the MSIX package that will be created by this task. 上面示例中的路径使用预定义的变量 ArtifactStagingDirectory,该路径是代理上用于存储项目的本地路径,在此处用于存储稍后可使用发布项目任务发布的任务输出文件。The path in the example above uses predefined variable Build.ArtifactStagingDirectory which is the local path on the agent to store artifacts, and is used here to store task output files which can later be published using a publish artifacts task.
  • 使用 MSBuild 生成解决方案 - 选择此选项可使用 msbuild 为指定的目标平台生成解决方案。Build Solution with MSBuild - Select this option to build your solution with msbuild for the specified target platform. 如果已经有了只需要打包的二进制文件,请将框保留为未选中状态。Leave the box unchecked if you already have binaries that just need to be packaged. 如果将框保留为未选中状态,则系统将要求你提供二进制文件的路径。If you leave the box unchecked, you will be asked to provide the path to your binaries.
  • 要生成的项目 - 提供需要生成的项目或解决方案文件的路径。Project to Build - Provide the path to your project or solution file that needs to be built.
  • 生成前清理 - 如果希望任务在生成之前运行清理生成,请选中此复选框。Clean before Building - Select this checkbox if you want the task to run a clean build prior to the build.
  • 生成 MSIX 捆绑 - 选择此复选框可生成 MSIX 捆绑,而不是包。Generate MSIX Bundle - Select this checkbox to generate an MSIX bundle instead of a package. 请确保在“输出路径”选项中将输出文件命名为 .msixbundle 扩展名,而不是 .msix。Make sure to name your output file in the Output Path option with a .msixbundle extension instead of .msix.
  • 配置 - 在调试和版本生成配置之间进行选择 。Configuration - Choose between Debug and Release build configurations.
  • 平台 - 指定目标生成平台,例如 x64、x86、任何 CPU 。Platform - Specify the target build platform, for example, x64, x86, Any CPU.
  • 更新清单中的应用版本 - 选择此复选框可从应用的 .appxmanifest 文件中所指定的应用中更改应用版本。Update App Version in Manifest - Select this checkbox to change the app version from the one specified in the app's .appxmanifest file. 这不会覆盖 .appxmanifest 文件,但会更改生成的输出 MSIX 包中的应用版本。This will not overwrite the .appxmanifest file, but change the app version in the generated output MSIX package. 如果选择此选项,系统将要求你提供清单文件的路径,以及要为应用设置的应用版本号。If this option is selected, you will be asked to provide the path to the manifest file, and the app version number to set for the app.
  • 应用程序包分发模式 - 从下拉菜单中选择要生成 Microsoft Store 应用包或非 Microsoft Store 应用包的模式。Application Package Distribution Mode - Select the mode from the dropdown menu to generate a Store app package or non-Store app package.
  • 用于 MSBuild 的高级选项 - 使用高级选项自定义 MSBuild。Advanced Options for MSBuild - Customize your MSBuild by using advanced options.

MSIX 包签名MSIX package signing

签名任务

  • 显示名称 - 自定义任务名称Display name - Customize your task name
  • 要签署的包 - MSIX 包签名任务使用 SignTool 来签名与此路径匹配的所有文件,而不管它们是 MSIX 包还是包。Package to sign - The MSIX package signing task uses SignTool to sign all files matching this path, regardless of whether they are MSIX packages or bundles.
  • 证书文件 - 从下拉列表中选择受信任的证书来对应用进行签名,或使用齿轮图标上传证书文件。Certificate file - Select your trusted certificate to sign the app from the dropdown, or upload a certificate file by using the gear icon.
  • 密码变量 - 存储用于访问证书文件以进行签名的密码的变量名称。Password Variable - The name of the variable which stores the password used to access the certificate file for signing. 请注意,这不是密码本身,而是可以在“库”下设置的变量名称。Note that this is NOT the password itself, but rather the variable name, which can be set under Library.
  • 时间戳服务器 - 用于指定时间戳服务器地址的 URL。Time Stamp Server - A URL that specifies the address of a time stamping server. 这是一个可选参数。This is an optional parameter.

用于 MSIX 的应用安装程序文件App installer file for MSIX

appinstaller

  • 显示名称 - 自定义任务名称Display name - Customize your task name
  • - 这是要为其创建应用安装程序的包或捆绑的路径。Package - This is the path to the package or bundle you want to create an App Installer for.
  • 输出文件路径 - 这是要写入的应用安装程序文件的路径。Output File Path - This is the path of the App Installer file to be written.
  • 创建应用安装程序文件的方法 - 选择是创建新的应用安装程序文件还是更新现有的应用程序安装程序文件。Method to Create App Installer File - Choose whether to create a new App Installer file or update an existing one. 如果选择更新现有应用安装程序文件,系统将要求你提供现有应用安装程序文件的路径。If you choose to update an existing one, you will be asked to provide the path to the existing App Installer file.
  • 应用安装程序文件的版本 - 将给出的版本号。Version for App Installer file - The version number which will be given. 必须采用格式(主版本号).(次版本号).(生成号).(修订号) 。Must take the form (major).(minor).(build).(revision).
  • URI - 重定向的应用安装程序文件的 Web URI。URI - Web URI to the redirected App Installer file.
  • 主包/捆绑 URI - 应用包/捆绑位置的 URI。Main Package/Bundle URI - URI to the app package/bundle location.
  • 启动时更新 - 选择此选项可将应用设置为在启动时检查更新。Update On Launch - Select this to set the app to check for updates when launched. 如果选中此复选框,系统将要求你提供详细信息,例如“更新检查之间的小时数”、是否“更新时向用户显示 UI”,以及是否想要“更新以阻止应用激活” 。If this checkbox is selected, you will be asked to provide details like Hours Between Update Checks, whether to Show UI to User when Updating, and whether you want the Update to Block App Activation.

为 MSIX 应用附加创建包Create package for MSIX app attach

应用附加

  • 显示名称 - 自定义任务名称。Display name - Customize your task name.
  • 包路径 - 这是 MSIX 包/捆绑的路径。Package Path - This is the path to the MSIX package/bundle.
  • VHDX 输出路径 - 这是将由此任务创建的 VHDX 文件的路径。VHDX Output Path - This is the path of the VHDX file that will be created by the task.
  • VHDX 大小 - VHDX 的最大大小 (MB)。VHDX size - The maximum size in MBs of the VHDX.

配置完所有任务后,可以使用“发布生成项目”任务将所有项目从临时位置发布到 Azure Pipelines 项目或所选文件共享。After configuring all the tasks, you can use a Publish build artifacts task to drop all the artifacts from the temp location to Azure Pipelines artifacts or a file share of your choice.

提供反馈的方法Ways to provide Feedback

欢迎提供有关 MSIX 打包扩展的反馈。We would love to hear your feedback on the MSIX Packaging Extension. 请通过以下渠道联系我们:Reach out to us via the following channels: