从源代码通过 MSIX Core 创建 MSIX 包Create an MSIX package with MSIX Core from source code

.Msix Core 引入了 .msix 部署来选择以前版本的 Windows。MSIX Core brings MSIX deployment to select previous versions of Windows. 可以利用 .MSIX 核心安装程序,使用 ClickOnce 创建应用程序。You can leverage the MSIX Core installer to create an application using ClickOnce. 这样,用户就可以下载 setup.exe,并通过 .MSIX 核心安装程序安装 .MSIX 应用程序。This will allow your users to download a setup.exe and install the MSIX app through the MSIX Core installer.

在 web 服务器上托管你的应用程序Host your app on a web server

若要使用 .MSIX 核心安装程序准备好应用程序,需要在 web 服务器上托管应用程序包。To get your app ready for bootstrapping with the MSIX Core installer, you’ll need to host your app package on a web server. 本部分提供有关如何在 Azure上设置 web 应用、 Internet Information Services (IIS) Amazon Web Services (AWS) 的详细信息。This section provides details about how to set up a web app on Azure, Internet Information Services (IIS), and Amazon Web Services (AWS).


若要使用此选项,必须拥有 Azure 订阅。To use this option you must have an Azure subscription. 若要获取一个帐户,请参阅 Azure 帐户页To obtain one, see the Azure account page.

创建 Azure Web 应用Create an Azure Web App

若要开始操作,请转到 " Azure 门户" 页 ,然后执行以下步骤:To get started go to the Azure portal page and follow these steps:

  1. 单击“创建资源”。Click Create a Resource.
  2. 单击 " web ",然后选择 " web 应用"。Click Web and select Web App.
  3. 在 " 实例详细信息" 下,创建一个唯一的应用名称,然后为应用选择适当的设置。Under Instance Details, create a unique app name and select the appropriate settings for your app. 例如,你将需要在 代码或 Docker 容器运行时堆栈之间进行选择。For example, you will need to choose between Code or Docker Container and the Runtime Stack. 否则,保留所有其他默认值。Otherwise, leave everything else default.
  4. 单击 " 创建 " 并完成向导。Click Create and finish the wizard.

承载应用包和网页Host the app package and the web page

  1. 创建 web 应用后,选择该应用。After you create the web app, select the app.
  2. 在 " 开发工具" 下,单击 应用服务编辑器Under Development Tools, click App Service Editor.
  3. 在编辑器中,有一个默认的 hostingstart.html 文件。In the editor, there is a default hostingstart.html file. 右键单击文件资源管理器的空白区域,然后选择 " 上传文件 " 以开始上传应用程序包。Right-click in the empty space of File Explorer and select Upload Files to begin uploading your app packages.
  4. 再次右键单击 "文件资源管理器" 面板的空白区域,然后选择 " 新建文件 " 以创建新文件。Right-click in the empty space of the File Explorer panel again and select New Files to create a new file. 将该文件命名为默认 HTML 页面所需的名称。Name the file what you want your default HTML page to be.

为应用包 MIME 类型配置 web 应用Configure the web app for app package MIME types

向 web 应用添加一个名为 Web.config 的新文件。Add a new file named Web.config to the web app. 打开 Web.config 文件,并将以下 XML 添加到该文件。Open the Web.config file and add the following XML to the file.

<?xml version="1.0" encoding="utf-8"?>
    <!--This is to allow the web server to serve resources with the appropriate file extensions-->
      <mimeMap fileExtension=".appx" mimeType="application/appx" />
      <mimeMap fileExtension=".msix" mimeType="application/msix" />

Internet 信息服务 (IIS)Internet Information Services (IIS)

IIS 是一个可选的 Windows 功能。IIS is an optional Windows feature. 若要安装 IIS:To install IIS:

  1. 单击 " 启动 ",然后搜索 "打开或关闭 Windows 功能"Click Start and search for Turn Windows features on or off.
  2. 选择 Internet Information ServicesSelect Internet Information Services.
  3. 另外,请确保安装 ASP.NET 4.5 或更高版本。Also make sure you install ASP.NET 4.5 or greater. 在 " Windows 功能" 对话框中,展开 " Internet Information Services -> World Wide Web 服务 -> 应用程序开发功能",然后选择大于或等于ASP.NET 4.5ASP.NET版本。In the Windows Features dialog, expand Internet Information Services -> World Wide Web Services -> Application Development Features, and select a version of ASP.NET that is greater than or equal to ASP.NET 4.5.
  4. 单击 "确定" 开始安装。Click OK to begin the installation.

Visual Studio 2017 (或更高版本) 和 Web 开发工具是必需的。Visual Studio 2017 (or a later version) and Web Development Tools are required. 如果已安装 Visual Studio 2017 或更高版本,请确保已安装 ASP.NET 和 Web 开发工作负荷。If you already have Visual Studio 2017 or a later version installed, make sure you have the ASP.NET and Web development workloads installed. 否则,请从 此处安装 Visual Studio。Otherwise, install Visual Studio from here.

构建 Web 应用Build a web app

以管理员身份启动 Visual Studio,并使用空项目模板创建新的 Visual c # Web 应用程序 项目。Start Visual Studio as an administrator and create a new Visual C# Web Application project with an empty project template.

将 IIS 配置为 Web 应用Configure IIS with your Web app

  1. 解决方案资源管理器中,右键单击根项目,然后选择 " 属性"。In Solution Explorer, right-click on the root project and select Properties.
  2. 在 "属性" 中,选择 " Web " 选项卡。In properties, select the Web tab.
  3. 在 " 服务器 " 部分,从下拉菜单中选择 " 本地 IIS ",然后单击 " 创建虚拟目录"。In the Servers section, choose Local IIS from the dropdown menu and click Create Virtual Directory.

将应用程序包添加到 web 应用程序Add the app package to the web application

将要分发的应用包添加到 web 应用程序:Add the app package that you want to distribute to the web application:

  1. 解决方案资源管理器中,右键单击项目节点。In Solution Explorer, right-click the project node.
  2. 选择 "添加 -> 新文件夹",并将文件夹命名为 ""。Select Add -> New Folder and name the folder packages.
  3. 若要将应用包添加到文件夹,请右键单击 "包" 文件夹,然后选择 "添加 -> 现有项"。To add app packages to the folder, right-click the packages folder and select Add -> Existing Item. 浏览到应用包位置。Browse to the app package location.

创建 Web 页Create a web page

根据需要创建 HTML 页面或任何其他 web 应用。Create an HTML page or any other web app as required per your needs. 添加新 setup.exe 的链接。Add the link of your new setup.exe.

为应用包 MIME 类型配置 web 应用Configure the web app for app package MIME types

从 "解决方案资源管理器" 打开 Web.config 文件,并在元素中添加以下 XML Open the Web.config file from the solution explorer and add the following XML within the element.

  <!--This is to allow the web server to serve resources with the appropriate file extensions-->
    <mimeMap fileExtension=".appx" mimeType="application/appx" />
    <mimeMap fileExtension=".msix" mimeType="application/msix" />

Amazon Web Services (AWS)Amazon Web Services (AWS)

若要使用此选项,必须具有 AWS 成员身份。To use this option you must have an AWS membership. 有关详细信息,请参阅 AWS 帐户详细信息。For more information, see AWS account details.

创建 Amazon S3 存储桶并上传 .MSIX 包和网页Create an Amazon S3 bucket and upload your MSIX packages and web pages

Amazon 简单存储服务 (S3) 是用于收集、存储和分析数据的 AWS 产品。Amazon Simple Storage Service (S3) is an AWS offering for collecting, storing and analyzing data. 使用 S3 存储桶,可以方便地托管 Windows 10 应用包和网页以进行分发。S3 buckets are a convenient way to host Windows 10 app packages and web pages for distribution.

  1. 登录到 AWS。Log in to AWS. 在 " 服务 " 下找到 " S3"。Under Services find S3.
  2. 选择 " 创建存储桶 ",然后输入你的网站的 存储桶名称Select Create bucket and enter a Bucket name for your website. 按照提示设置属性和权限的对话框。Follow the dialog prompts for setting properties and permissions. 若要确保你的 Windows 10 应用可以从你的网站分发,请为你的 bucket 启用 " 读取 " 和 " 写入 " 权限,然后选择 " 授予此 bucket 的公共读取权限"。To ensure that your Windows 10 app can be distributed from your website, enable Read and Write permissions for your bucket and select Grant public read access to this bucket. 单击 " 创建存储桶 " 完成此步骤。Click Create bucket to finish this step.
  3. 完成后,将 .MSIX 包和网页上传到 S3 存储桶。When you are finished, upload your MSIX packages and web pages to the S3 bucket.

为应用包 MIME 类型配置 web 应用Configure the web app for app package MIME types

使用 web 服务接口(如 S3 browser)   添加新的 默认 HTTP 标头Using a web service interface like S3 browser to add a new Default HTTP Headers.

  1. 导航到 " 工具 ",然后选择 " 默认 HTTP 标头"。Navigate to Tools and select Default HTTP Headers.
  2. 默认的 HTTP 标头 对话框中,单击 " 添加"。In the Default HTTP Headers dialog, click Add.
  3. 在 " 添加新的默认 HTTP 标头 " 对话框中,指定 bucket 名称、文件名、标头名称和标头值,然后单击 " 添加新标头"。In the Add New Default HTTP Headers dialog, specify the bucket name, file name, header name, and header value, and then click Add new header.
    • Bucket 名称: .msixBucket name: msix-packages
    • 文件名: *. .msixFile name: *.msix
    • 标头名称: content-typeHeader name: Content-Type
    • 标头值: application/.msixHeader value: application/msix


 AWS 具有一些必须遵循的严格指导原则。 AWS have some strict guidelines you will have to follow. 例如,Bucket 名称必须是唯一的,因此,如果使用上面的示例,则需要更改存储桶名称。For example, Bucket names are required to be unique and therefore if you are using the example above, you will need to change the Bucket name.

使用 .MSIX 核心安装程序生成 ClickOnce 应用程序Use the MSIX Core installer to build the ClickOnce application

查找应用程序应用程序 ClickOnce setup.exe。Find your application application ClickOnce setup.exe.

运行 URL 命令以创建新 setup.exeRun URL command to create new setup.exe

请确保按照说明在 Visual Studio 中克隆、构建和发布 .MSIX Core 解决方案。Make sure you have followed the instructions to clone, build and publish the MSIX Core solution in Visual Studio.

导航到下载 setup.exe 文件的目录,并运行以下命令:Navigate to the directory where you downloaded the setup.exe file and then run this command:

setup-exe - url=<location of your msix in the webservice>

签署应用程序Sign the application

由于上一步骤创建了新的 setup.exe,因此你将需要再次对应用进行签名,以验证你是应用程序的受信任发布者,并建立应用程序的完整性。Because the previous step created a new setup.exe, you will need to sign the app again to verify that you're a trusted publisher of the application and to establish the integrity of the application. 你可以使用 SignTool 并提供你的证书。You can use the SignTool and provide your certificate.

向用户分发应用程序Distribute the application to your users

你现在可以使用其网站上的链接或下载按钮指向新 setup.exe。You can now point to the new setup.exe with a link or download button on their website. .MSIX Core 面向 Windows 10 版本1703及更早版本上的用户。MSIX Core is targeted towards users on Windows 10, version 1703 and earlier. 应用程序安装程序是适用于 Windows 1709 或更高版本上的 .msix 包的理想安装过程。The App Installer is the ideal installation process for MSIX packages on Windows 1709 or a later version. 应用安装程序可优化使用者端的磁盘空间,并可直接从 HTTP 位置安装应用。App Installer optimizes for disk space on the consumer side and can directly install apps from HTTP locations. .MSIX 核心将检测使用者是否在 Windows 1709 或更高版本上,并将其重定向到应用安装程序。MSIX Core will detect if a consumer is on Windows 1709 or a later version and redirect them to App Installer.

在 Microsoft Edge 中,可以调用 getHostEnvironmentValue ( # B1 方法,返回值中的 os-生成 字段将指定该用户的操作系统版本。On Microsoft Edge, you can call the getHostEnvironmentValue() method and the os-build field in the return value will specify the OS version of the user. 然后,你可以在此处提示安装过程,使用适用于 windows 10 版本1703和) 更低版本的 .MSIX Core (、适用于 Windows 10 版本1709和) 更高版本的应用程序安装 (。From there, you can then prompt the installation process to use MSIX Core (for Windows 10, version 1703 and earlier) or App Installer (for Windows 10, version 1709 and later).

用户体验User experience

用户只需从开发人员的网页下载并运行 setup.exe。Users simply download and run the setup.exe from the developer’s webpage.

  • 如果用户 setup.exe 运行时尚未安装 .MSIX 核心安装程序,则用户将看到 ClickOnce 提示符,并单击 " 安装 " 以安装 .msix Core 安装程序。If the MSIX Core installer is not yet installed when the user runs setup.exe, the user sees the ClickOnce prompt and they click Install to install the MSIX Core installer. 安装程序将自动启动并显示开发人员的查询字符串中指定的 .MSIX 包的安装屏幕,以便用户可以安装应用程序。The installer automatically launches and shows the install screen for the MSIX package specified in the developer’s query string so the users can install the app.
  • 如果 .MSIX 核心安装程序已在用户运行 setup.exe 时安装,则 .MSIX Core 安装程序会自动启动,并显示在用户安装应用程序的查询字符串中指定的 .MSIX 包的安装屏幕。If the MSIX Core installer is already installed when the user runs setup.exe, the MSIX Core installer automatically launches and shows the install screen for the MSIX package specified in the query string for users to install the app.