手动创建应用安装程序文件Create an App Installer file manually

本文介绍如何手动创建用于定义 相关集的应用安装程序文件。This article shows how to manually create an App Installer file that defines a related set. 相关集不是一个实体,而是主要包和可选包的组合。A related set is not one entity, but rather a combination of a main package and optional packages.

为了能够将相关集作为一个实体来安装,我们必须能够将主要包和可选包指定为一个整体。To be able to install a related set as one entity, we must be able to specify the main package and optional package as one. 为此,我们需要创建一个具有 appinstaller 扩展名的 XML 文件来定义相关集。To do this, we will need to create an XML file with an .appinstaller extension to define a related set. 应用安装程序使用 appinstaller 文件,并允许用户通过单击来安装所有已定义的包。App Installer consumes the .appinstaller file and allows the user to install all of the defined packages with a single click.

应用安装程序文件示例App Installer file example

在深入了解更多详细信息之前,下面是一个完整的示例 .msixbundle *. appinstaller 文件:Before we go in to more detail, here is a complete sample msixbundle *.appinstaller file:

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
    xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"
    Version="1.0.0.0"
    Uri="http://mywebservice.azurewebsites.net/appset.appinstaller" >

    <MainBundle
        Name="Contoso.MainApp"
        Publisher="CN=Contoso"
        Version="2.23.12.43"
        Uri="http://mywebservice.azurewebsites.net/mainapp.msixbundle" />

    <OptionalPackages>
        <Bundle
            Name="Contoso.OptionalApp1"
            Publisher="CN=Contoso"
            Version="2.23.12.43"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp1.msixbundle" />

        <Bundle
            Name="Contoso.OptionalApp2"
            Publisher="CN=Contoso"
            Version="2.23.12.43"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp2.msixbundle" />

        <Package
            Name="Fabrikam.OptionalApp3"
            Publisher="CN=Fabrikam"
            Version="10.34.54.23"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp3.msix"
            ProcessorArchitecture="x64" />

    </OptionalPackages>
    
    <UpdateSettings>
    <OnLaunch HoursBetweenUpdateChecks="0"/>   
  </UpdateSettings>

</AppInstaller>

在部署期间,会根据 Uri 元素中引用的应用包来验证应用安装程序文件。During deployment, the App Installer file is validated against the app packages referenced in the Uri element. 因此,NamePublisherVersion 应与应用程序包清单中的 Package/Identity 元素匹配。So, the Name, Publisher and Version should match the Package/Identity element in the app package manifest.

如何创建应用安装程序文件How to create an App Installer file

若要作为一个实体来分配相关集,你必须创建一个应用安装程序文件,其中包含该 appinstaller 架构所需的元素。To distribute your related set as one entity, you must create an App Installer file that contains the elements that are required by that appinstaller schema.

第 1 步:创建 *.appinstaller 文件Step 1: Create the *.appinstaller file

使用文本编辑器,创建一个文件(其中将包含 XML)并将其命名为 <文件名>.appinstallerUsing a text editor, create a file (which will contain XML) and name it <filename>.appinstaller

第 2 步:添加基本模板Step 2: Add the basic template

基本模板包括应用安装程序文件信息。The basic template includes the App Installer file information.

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
    xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"
    Version="1.0.0.0"
    Uri="http://mywebservice.azurewebsites.net/appset.appinstaller" >
</AppInstaller>

第 3 步:添加主要包信息Step 3: Add the main package information

如果主要应用程序包是 .msix 或 .appx 文件,请使用 <MainPackage> ,如下所示。If the main app package is an .msix or .appx file, then use <MainPackage>, as shown below. 请确保包含 ProcessorArchitecture,因为它对非捆绑包是必需的。Be sure to include the ProcessorArchitecture, as it is mandatory for non-bundle packages.

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
    xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"
    Version="1.0.0.0"
    Uri="http://mywebservice.azurewebsites.net/appset.appinstaller" >

    <MainPackage
        Name="Contoso.MainApp"
        Publisher="CN=Contoso"
        Version="2.23.12.43"
        ProcessorArchitecture="x64"
        Uri="http://mywebservice.azurewebsites.net/mainapp.msix" />

</AppInstaller>

如果主应用包为 .msixbundle 或 .appxbundle 或文件,则使用代替,如下 <MainBundle> <MainPackage> 所示。If the main app package is an .msixbundle or .appxbundle or file, then use the <MainBundle> in place of <MainPackage> as shown below. 对于捆绑包,ProcessorArchitecture 不是必需的。For bundles, ProcessorArchitecture is not required.

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
    xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"
    Version="1.0.0.0"
    Uri="http://mywebservice.azurewebsites.net/appset.appinstaller" >

    <MainBundle
        Name="Contoso.MainApp"
        Publisher="CN=Contoso"
        Version="2.23.12.43"
        Uri="http://mywebservice.azurewebsites.net/mainapp.msixbundle" />

</AppInstaller>

<MainBundle><MainPackage> 属性中的信息应该分别与应用程序包清单或应用包清单中的 Package/Identity 元素匹配。The information in the <MainBundle> or <MainPackage> attribute should match the Package/Identity element in the app bundle manifest or app package manifest respectively.

第 4 步:添加可选包Step 4: Add the optional packages

类似于主应用包属性,如果可选包可以是应用包或应用程序包,则 <OptionalPackages> 属性中的子元素应该分别是 <Package><Bundle>Similar to the main app package attribute, if the optional package can be either an app package or an app bundle, the child element within the <OptionalPackages> attribute should be <Package> or <Bundle> respectively. 子元素中的包信息应该与程序包或程序包清单中的 Identity 元素相匹配。The package information in the child elements should match the identity element in the bundle or package manifest.

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
    xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"
    Version="1.0.0.0"
    Uri="http://mywebservice.azurewebsites.net/appset.appinstaller" >

    <MainBundle
        Name="Contoso.MainApp"
        Publisher="CN=Contoso"
        Version="2.23.12.43"
        Uri="http://mywebservice.azurewebsites.net/mainapp.msixbundle" />

    <OptionalPackages>
        <Bundle
            Name="Contoso.OptionalApp1"
            Publisher="CN=Contoso"
            Version="2.23.12.43"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp1.msixbundle" />

        <Bundle
            Name="Contoso.OptionalApp2"
            Publisher="CN=Contoso"
            Version="2.23.12.43"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp2.msixbundle" />

        <Package
            Name="Fabrikam.OptionalApp3"
            Publisher="CN=Fabrikam"
            Version="10.34.54.23"
            ProcessorArchitecture="x64"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp3.msix" />

    </OptionalPackages>

</AppInstaller>

第 5 步:添加依赖项Step 5: Add dependencies

在依赖项元素中,你可以指定主要包或可选包所需的框架包。In the dependencies element, you can specify the required framework packages for the main package or the optional packages.

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
    xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"
    Version="1.0.0.0"
    Uri="http://mywebservice.azurewebsites.net/appset.appinstaller" >

    <MainBundle
        Name="Contoso.MainApp"
        Publisher="CN=Contoso"
        Version="2.23.12.43"
        Uri="http://mywebservice.azurewebsites.net/mainapp.msixbundle" />

    <OptionalPackages>
        <Bundle
            Name="Contoso.OptionalApp1"
            Publisher="CN=Contoso"
            Version="2.23.12.43"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp1.msixbundle" />

        <Bundle
            Name="Contoso.OptionalApp2"
            Publisher="CN=Contoso"
            Version="2.23.12.43"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp2.msixbundle" />

        <Package
            Name="Fabrikam.OptionalApp3"
            Publisher="CN=Fabrikam"
            Version="10.34.54.23"
            ProcessorArchitecture="x86"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp3.msix" />

    </OptionalPackages>

    <Dependencies>
        <Package Name="Microsoft.VCLibs.140.00" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="14.0.24605.0" ProcessorArchitecture="x86" Uri="http://foobarbaz.com/fwkx86.appx" />
        <Package Name="Microsoft.VCLibs.140.00" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="14.0.24605.0" ProcessorArchitecture="x64" Uri="http://foobarbaz.com/fwkx64.appx" />
    </Dependencies>

</AppInstaller>

第 6 步:添加更新设置Step 6: Add Update setting

应用安装程序文件还可以指定更新设置,以便在发布较新的应用安装程序文件时可以自动更新相关集。The App Installer file can also specify update setting so that the related sets can be automatically updated when a newer App Installer file is published. 是一个可选元素。 is an optional element. OnLaunch 选项中,指定应在应用启动时进行更新检查,HoursBetweenUpdateChecks = "12" 指定应每隔12小时执行一次更新检查。Within the OnLaunch option specifies that update checks should be made on app launch, and HoursBetweenUpdateChecks="12" specifies that an update check should be made every 12 hours. 如果未指定 HoursBetweenUpdateChecks,则用于检查更新的默认时间间隔为 24 小时。If HoursBetweenUpdateChecks is not specified, the default interval used to check for updates is 24 hours. 其他类型的更新,如后台更新,可以在 "更新设置"架构中找到;在 OnLaunch架构中可以找到其他类型的启动更新,如使用提示更新的更新。Additional types of updates, like background updates can be found in the Update Settings schema; Additional types of on-launch updates like updates with a prompt can be found in the OnLaunch schema

<?xml version="1.0" encoding="utf-8"?>
<AppInstaller
    xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2"
    Version="1.0.0.0"
    Uri="http://mywebservice.azurewebsites.net/appset.appinstaller" >

    <MainBundle
        Name="Contoso.MainApp"
        Publisher="CN=Contoso"
        Version="2.23.12.43"
        Uri="http://mywebservice.azurewebsites.net/mainapp.msixbundle" />

    <OptionalPackages>
        <Bundle
            Name="Contoso.OptionalApp1"
            Publisher="CN=Contoso"
            Version="2.23.12.43"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp1.msixbundle" />

        <Bundle
            Name="Contoso.OptionalApp2"
            Publisher="CN=Contoso"
            Version="2.23.12.43"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp2.msixbundle" />

        <Package
            Name="Fabrikam.OptionalApp3"
            Publisher="CN=Fabrikam"
            Version="10.34.54.23"
            ProcessorArchitecture="x86"
            Uri="http://mywebservice.azurewebsites.net/OptionalApp3.msix" />

    </OptionalPackages>

    <Dependencies>
        <Package Name="Microsoft.VCLibs.140.00" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="14.0.24605.0" ProcessorArchitecture="x86" Uri="http://foobarbaz.com/fwkx86.appx" />
        <Package Name="Microsoft.VCLibs.140.00" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="14.0.24605.0" ProcessorArchitecture="x64" Uri="http://foobarbaz.com/fwkx64.appx" />
    </Dependencies>

    <UpdateSettings>
        <OnLaunch HoursBetweenUpdateChecks="12" />
    </UpdateSettings>

</AppInstaller>

有关 XML 架构的所有详细信息,请参阅应用安装程序文件参考For all of the details on the XML schema, see App Installer file reference.

备注

应用安装程序文件类型是 Windows 10 版本 1709 (windows 10 秋季创建者更新) 中的新类型。The App Installer file type is new in Windows 10, version 1709 (the Windows 10 Fall Creators Update). 在以前版本的 Windows 10 上,不支持使用应用安装程序文件部署 Windows 10 应用。There is no support for deployment of Windows 10 apps using an App Installer file on previous versions of Windows 10. 从 Windows 10 版本1803开始, HoursBetweenUpdateChecks 元素可用。The HoursBetweenUpdateChecks element is available starting in Windows 10, version 1803.