使用 MSIX SDK 在非 Windows 10 平臺上散發 MSIX 套件

不論客戶端裝置上的 OS 平台為何,MSIX SDK 都為開發人員提供將套件內容發佈至用戶端裝置的通用方式。 這可讓開發人員一次封裝其應用程式內容,而不必為每個平臺封裝。

為了利用 MSIX SDK 以及將套件內容發佈至多個平臺的能力,我們提供一種方式來指定您希望套件擷取的目標平臺。 這表示您可以確保套件內容只會視需要從套件擷取。

下表顯示指令清單中要宣告的目標裝置系列。

平台 系列 目標裝置系列 備註
Windows 10 手機





















Platform.All























Windows.Universal Windows.Mobile 行動裝置
桌面 Windows.Desktop 電腦
Xbox Windows.Xbox Xbox 主控台
Surface Hub Windows.Team 大型螢幕 Win 10 裝置
HoloLens Windows.Holographic VR/AR 頭戴式裝置
IoT Windows.IoT IoT 裝置
iOS 手機 Apple.Ios.All Apple.Ios。電話 i 電話,觸控
Tablet Apple.Ios.Tablet iPad mini、iPad、iPad Pro
TV Apple.Ios.TV Apple TV
觀看 Apple.Ios.Watch iWatch
MacOS 桌面 Apple.MacOS.All MacBook Pro、MacBook Air、Mac Mini、iMac
Android 手機 Google.Android.All Google.Android。電話 以任何 Android 類別為目標的行動裝置
Tablet Google.Android.Tablet Android 平板電腦
桌面 Google.Android.Desktop Chromebook
TV Google.Android.TV Android 大型螢幕裝置
觀看 Google.Android.Watch Google 齒輪設備
Windows 7 Windows7.Desktop Windows 7 裝置
8 Windows8.Desktop Windows 8/8.1 裝置
Web Microsoft Web.All Web.Edge.All Edge Web 引擎應用程式
Android Web.Blink.All 閃爍 Web 引擎應用程式
Chrome Web.Chromium.All Chrome Web 引擎應用程式
iOS Web.Webkit.All Webkit Web 引擎應用程式
MacOS Web.Safari.All Safari Web 引擎應用程式
Linux Any/All Linux.All 所有 Linux 發行版

在應用程式套件指令清單檔案中,如果您想要只在特定平臺和裝置上擷取套件內容,則必須包含適當的目標裝置系列。 如果您想要讓套件受到所有平台和裝置類型的支援,請選擇 [平臺.All ] 作為目標裝置系列。 同樣地,如果您想要只支援 Web 應用程式中的套件,請選擇 [Web.All]。

範例指令清單檔 (AppxManifest.xml)

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
         xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
         xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
         xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
         IgnorableNamespaces="mp uap uap3">

  <Identity Name="BestAppExtension"
            Publisher="CN=awesomepublisher"
            Version="1.0.0.0" />

  <mp:PhoneIdentity PhoneProductId="56a6ecda-c215-4864-b097-447edd1f49fe" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

  <Properties>
    <DisplayName>Best App Extension</DisplayName>
    <PublisherDisplayName>Awesome Publisher</PublisherDisplayName>
    <Description>This is an extension package to my app</Description>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>

  <Resources>
    <Resource Language="x-generate"/>
  </Resources>

  <Dependencies>
    <TargetDeviceFamily Name="Platform.All" MinVersion="0.0.0.0" MaxVersionTested="0.0.0.0"/>
  </Dependencies>

  <Applications>
    <Application Id="App">
      <uap:VisualElements
          DisplayName="Best App Extension"
          Description="This is the best app extension"
          BackgroundColor="white"
          Square150x150Logo="images\squareTile-sdk.png"
          Square44x44Logo="images\smallTile-sdk.png"
          AppListEntry="none">
      </uap:VisualElements>

      <Extensions>
        <uap3:Extension Category="Windows.appExtension">
          <uap3:AppExtension Name="add-in-contract" Id="add-in" PublicFolder="Public" DisplayName="Sample Add-in" Description="This is a sample add-in">
            <uap3:Properties>
               <!--Free form space-->
            </uap3:Properties>
          </uap3:AppExtension>
        </uap3:Extension>
      </Extensions>

    </Application>
  </Applications>
</Package>

平臺版本

在上述範例指令清單檔中,以及平台名稱,也有參數可指定 MinVersionMaxVersionTested 這些參數用於 Windows 10 平臺上。 在 Windows 10 上,套件只會部署在大於 MinVersion 的 Windows 10 OS 版本上。 在其他非 Windows 10 平臺上,MinVersion 和 MaxVersionTested 參數不會用來宣告是否擷取套件內容。

如果您想要針對所有平臺使用套件(Windows 10 和非 Windows 10),建議您使用 MinVersion 和 MaxVersionTested 參數來指定您希望應用程式運作的 Windows 10 OS 版本。 因此,您的指令清單的 [相依性] 區段看起來會像這樣:

  <Dependencies>
    <TargetDeviceFamily Name="Platform.All" MinVersion="0.0.0.0" MaxVersionTested="0.0.0.0"/>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.14393.0" MaxVersionTested="10.0.16294.0"/>
  </Dependencies>

MinVersionMaxVersionTested 是指令清單中的必要字段,而且它們必須符合四元表示法(#.#.#.#)。 如果您只針對非 Windows 10 平臺使用 MSIX 封裝 SDK,只需使用 '0.0.0.0' 作為 MinVersionMaxVersionTested 做為版本。

如何在所有平臺上有效地使用相同的套件(Windows 10 和非 Windows 10)

若要充分利用 MSIX 封裝 SDK,您必須以 Windows 10 上的應用程式套件和在其他平台上同時支援的部署方式來建置套件。 在 Windows 10 上,您可以將套件建置為 應用程式延伸模組。 如需應用程式延伸模組及其如何協助讓您的應用程式可延伸的詳細資訊,請參閱 應用程式延伸模塊 簡介部落格文章。

在本文稍早所示的指令清單檔案範例中,您會注意到 AppExtension 元素內的 Properties 元素。 指令清單檔的這個區段沒有執行驗證。 這可讓開發人員指定擴充功能和主機/用戶端應用程式之間的必要元數據。