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

無論用戶端裝置上的作業系統平臺為何,MSIX SDK 都能讓開發人員以通用方式將套件內容散發至用戶端裝置。 這可讓開發人員將應用程式內容封裝一次,而不必針對每個平臺進行封裝。

為了充分利用 MSIX SDK 以及將套件內容散發至多個平臺的功能,我們提供了一種方法來指定您要封裝解壓縮至的目標平臺。 這表示您可以根據自己的需求,確保封裝內容只從套件中解壓縮。

下表顯示要在資訊清單中宣告的目標裝置系列。

平台 系列 目標裝置系列 注意
Windows 10 電話





















Platform. All























Windows。普遍 Windows。移動 行動裝置
桌面 Windows。桌面 PC
Xbox Windows。Xbox Xbox 主控台
Surface Hub Windows。團隊 大型螢幕 Win 10 裝置
HoloLens Windows。全息 VR/AR 耳機
IoT Windows。IoT IoT 裝置
iOS 電話 蘋果. 全部 Apple. Ios。電話 iPhone,觸控
Tablet Apple. 平板電腦 iPad 迷你、iPad iPad Pro
電視 Apple.Ios.TV Apple TV
觀看 Apple. Watch iWatch
MacOS 桌面 MacOS。 MacBook Pro、MacBook Air、Mac 迷你、iMac
Android 電話 Google. Android. 全部 Google. Android。電話 以 Android 任何類別為目標的行動裝置
Tablet Google. Android 平板電腦 Android 平板電腦
桌面 Google. Android. Desktop Chromebook
電視 Google.Android.TV Android 大型螢幕裝置
觀看 Google. Android. 監看 Google 齒輪裝置
Windows 7 最為理想桌面 Windows 7 裝置
8 Windows8 桌面 Windows 8/8.1 裝置
Web Microsoft Web。全部 Web Edge. 全部 Edge web 引擎應用程式
Android Web。閃爍 閃爍 web 引擎應用程式
Chrome Web。Chromium。所有 Chrome web 引擎應用程式
iOS Webkit Webkit web 引擎應用程式
MacOS Web. Safari. 全部 Safari web 引擎應用程式
Linux 任何/所有 Linux。全部 所有 Linux 發行版本

在應用程式套件資訊清單檔案中,如果您只想要將套件內容解壓縮到特定平臺和裝置,則必須包含適當的目標裝置系列。 如果您想要在所有平臺和裝置類型上支援封裝的 bulid,請選擇 [ platform ] 作為目標裝置系列。 同樣地,如果您只想要在 web 應用程式中支援套件,請選擇 [ web]。

範例資訊清單檔 (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 作業系統版本。 在其他非 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 ' 作為MinVersion ,並使用MaxVersionTested作為版本。

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

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

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