表示包含套件中傳遞之部分功能或所有功能的應用程式。
元素階層
<Package>
└─ <Applications>
└─ <Application>
語法
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10">
...
<Application
Id = 'A required value. <!-- TODO: Add description for t:ST_ApplicationId -->'
Executable = 'An optional string between 1 and 256 characters in length that must end with ".exe" and cannot contain these characters: <, >, :, ", |, ?, or *.'
EntryPoint = 'An optional string between 1 and 256 characters in length that cannot start or end with a whitespace character.'
StartPage = 'An optional value. <!-- TODO: Add description for t:ST_ApplicationStartPage -->'
ResourceGroup = 'An optional alphanumeric string between 1 and 255 characters in length. Must begin with an alphabetic character.'
desktop4:Subsystem = 'An optional string that can have one of the following values: "console", or "windows".'
iot2:Subsystem = 'An optional string that can have one of the following values: "console", or "windows".'
uap10:Subsystem = 'An optional string that can have one of the following values: "console", or "windows".'
desktop4:SupportsMultipleInstances = 'An optional boolean value.'
iot2:SupportsMultipleInstances = 'An optional boolean value.'
uap10:SupportsMultipleInstances = 'An optional boolean value.'
uap11:CurrentDirectoryPath = 'An optional string that cannot contain these characters: <, >, |, ?, or *.'
uap11:Parameters = 'An optional string between 1 and 32767 characters in length with a non-whitespace character at its beginning and end.'
previewsecurity:TrustLevel = 'An optional string that can have one of the following values: "appContainer", "mediumIL", or "appSilo".'
uap10:TrustLevel = 'An optional string that can have one of the following values: "appContainer", or "mediumIL".'
uap10:RuntimeBehavior = 'An optional string that can have one of the following values: "windowsApp", "packagedClassicApp", or "win32App".'
uap10:HostId = 'An optional alphanumeric string between 1 and 255 characters in length. Must begin with an alphabetic character.'
uap10:Parameters = 'An optional string between 1 and 32767 characters in length with a non-whitespace character at its beginning and end.'
previewsecurity2:RuntimeBehavior = 'An optional string that can have one of the following values: "windowsApp", "packagedClassicApp", "win32App", or "appSilo".'
uap16:BaseNamedObjectsIsolation = 'An optional string that can have one of the following values: "none", or "package".'
uap17:BaseNamedObjectsIsolation = 'An optional string that can have one of the following values: "none", or "package".'
desktop11:AppLifecycleBehavior = 'An optional string that can have one of the following values: "systemManaged", or "unmanaged".' >
<!-- Child elements -->
VisualElementsChoice
ApplicationContentUriRules?
Extensions?
Properties?
</Application>
</Package>
Key
? 選擇性 (零或一個)
屬性
| 屬性 | Description | 資料類型 | Required | 預設值 |
|---|---|---|---|---|
| Id | 封裝內應用程式的唯一標識碼。 此值有時稱為套件相對應用程式識別碼 (PRAID)。 標識碼在套件內是唯一的,但並非全域。 系統上可能會有另一個套件使用相同的標識碼。 相同的標識碼不能在同一個套件中多次使用。 使用Visual Studio模板時,此屬性的預設值為App。 開發人員應該在指令清單中手動變更此專案。 應用程式在發佈到 Microsoft Store 後,不應更改該識別碼;若如此,會干擾該磁貼在開始畫面中的位置。 | 一個值。 | Yes | |
| 可執行檔 | 默認啟動可執行檔。 | 一個長度介於 1 到 256 字元之間的可選字串,必須以「.exe」結尾,且不能包含以下字元: <, >, :, “, |, ?, 或 *。 | No | |
| EntryPoint | 可啟動的類別識別碼。 | 一個長度介於 1 到 256 字元之間的可選字串,且不能以空白字元開頭或結尾。 | No | |
| StartPage | 處理延展性點的網頁。 | 一個可選的值。 | No | |
| 資源群組 | 標記,可用來將擴充功能啟用群組在一起,以供資源管理之用(例如 CPU 和記憶體)。 | 一個長度介於 1 到 255 字元之間的可選字母數字字串。 必須以字母字元開頭。 | No | |
| desktop4:子系統 | 指出應用程式是標準 UWP 應用程式還是 UWP 控制台應用程式。 | 一個可選字串,可以有以下其中一個值: console、 windows。 | No | |
| iot2:子系統 | 一個可選字串,可以有以下其中一個值: console、 windows。 | No | ||
| UAP10:子系統 | 指出應用程式是標準 UWP 應用程式還是 UWP 控制台應用程式。 | 一個可選字串,可以有以下其中一個值: console、 windows。 | No | |
| desktop4:支援多個實例 | 表示支援多個個別的 UWP 應用程式實例。 如需詳細資訊,請參閱一節。 | 選擇性布爾值。 | No | |
| iot2:支援多個實例 | 選擇性布爾值。 | No | ||
| uap10:支援多重實例 | 表示支援多個個別的 UWP 應用程式實例。 如需詳細資訊,請參閱一節。 | 選擇性布爾值。 | No | |
| uap11:CurrentDirectoryPath | 在啟動程序時指定初始目錄。 此屬性支援巨集。 如需詳細資訊,請參閱套件指令清單架構中的 巨集。 | 一個可選字串,無法包含以下字元: <、、 >|、?、* 。 | No | |
| uap11:Parameters | 包含要傳遞至延伸模組的命令行參數。 此屬性支援巨集。 如需詳細資訊,請參閱套件指令清單架構中的 巨集。 | 一個長度介於 1 到 32767 字元之間的可選字串,開頭和結尾都有非空白字元。 | No | |
| previewsecurity:TrustLevel | 一個可選字串,可以有以下其中一個值:appContainer、mediumIL、appSilo。 | No | ||
| uap10:TrustLevel | 指定延伸模組的信任層級。 | 一個可選字串,可以有以下其中一個值:appContainer、mediumIL。 | No | |
| uap10:RuntimeBehavior | 指定延伸模組的運行時間行為。 | 一個可選字串,可以有以下其中一個值: windowsApp、 packagedClassicApp、 win32App。 | No | |
| uap10:HostId | 指定擴充功能的主機運行時間標識碼。 | 一個長度介於 1 到 255 字元之間的可選字母數字字串。 必須以字母字元開頭。 | No | |
| uap10:Parameters | 包含要傳遞至延伸模組的命令行參數。 僅支援具有套件身分識別的桌面應用程式。 | 一個長度介於 1 到 32767 字元之間的可選字串,開頭和結尾都有非空白字元。 | No | |
| previewsecurity2:RuntimeBehavior | 一個可選字串,可以有以下其中一個值: windowsApp、 packagedClassicApp、 win32App、 appSilo。 | No | ||
| uap16:BaseNamedObjectsIsolation(基地命名物件隔離) | 啟用應用程式的BaseNameObject (BNO) 隔離。 | 一個可選字串,可以有以下其中一個值: none、 package。 | No | |
| uap17:BaseNamedObjectsIsolation(基地命名物件隔離) | 啟用應用程式的BaseNameObject (BNO) 隔離。 | 一個可選字串,可以有以下其中一個值: none、 package。 | No | |
| desktop11:AppLifecycleBehavior | 可讓應用程式覆寫與延伸模組運行時間行為相關聯的生命週期行為。 除非另有說明,否則 RuntimeBehavior 為「windowsApp」的應用程式或擴充功能,隱含的 AppLifecycleBehavior 為「systemManaged」。 若應用程式或擴充功能 RuntimeBehavior 為「packagedClassicApp」或「win32App」,除非另有說明,否則 AppLifecycleBehavior 隱含為「未受管理」。 | 一個可選字串,可以有以下其中一個值: systemManaged、 unmanaged。 | No |
子專案
| 子專案 | Description |
|---|---|
| uap:ApplicationContentUriRules | 指定 Web 內容中的哪些頁面可以存取系統的地理位置裝置(如果應用程式有權存取此功能),以及剪貼簿的存取權。 |
| Extensions | 定義應用程式的一或多個擴充點。 |
| uap7:Properties | 應用程式的屬性。 |
父元素
| 父元素 | Description |
|---|---|
| Applications | 代表組成套件的一或多個應用程式。 |
要求
| 項目 | 價值 |
|---|---|
| 命名空間 | http://schemas.microsoft.com/appx/manifest/foundation/windows10 |
| desktop11 | http://schemas.microsoft.com/appx/manifest/desktop/windows10/11 |
| Desktop4 | http://schemas.microsoft.com/appx/manifest/desktop/windows10/4 |
| 物聯網2 | http://schemas.microsoft.com/appx/manifest/iot/windows10/2 |
| 預覽安全性 | http://schemas.microsoft.com/appx/manifest/preview/windows10/security |
| 預覽安全2 | http://schemas.microsoft.com/appx/manifest/preview/windows10/security/2 |
| uap10 | http://schemas.microsoft.com/appx/manifest/uap/windows10/10 |
| UAP11 | http://schemas.microsoft.com/appx/manifest/uap/windows10/11 |
| UAP16 | http://schemas.microsoft.com/appx/manifest/uap/windows10/16 |
| UAP17 | http://schemas.microsoft.com/appx/manifest/uap/windows10/17 |
| 最低 OS 版本 |
備註
該 Application 元素包含與應用程式相關的可擴充點共有的屬性。 其他擴充點會使用此資訊來取得應用程式的相關信息。 Application 屬性也被用作啟動與管理應用程式實例時的 啟用資訊 (換句話說,描述如何啟動程序及其行為)。
StartPage 屬性僅適用於 JavaScript 應用程式。 如果沒有指定 StartPage ,則必須同時指定 Executable 和 EntryPoint 屬性(且僅適用於 C#、C++ 或 VB 應用程式)。
uap10 於 Windows 10 版本 2004(10.0;建造於19041年)
uap10命名空間(代表 uap10:RuntimeBehavior 和 uap10:TrustLevel)於 Windows 10 年引入,版本為 2004 年(10.0;建造於19041年)。 如果您的套件安裝在比這還舊的系統上,則您需要提供對等的屬性組合(請參閱下一節),否則啟用資訊將會不完整,安裝將會失敗。
但如果你的套件有 <TargetDeviceFamily MinVersion="10.0.19041.0">或更高,那它只會安裝在支援該 uap10 命名空間的系統上。 在這種情況下,你應該優先使用 uap10:RuntimeBehavior 和 uap10:TrustLevel 屬性,而不是舊有的等效組合(見下節)。
啟用資訊屬性的組合
你可以在 Application 元素上指定啟用資訊屬性;也可以選擇在應用程式範圍的 擴充 元素中指定。 如果擴充中沒有指定,則會繼承自父Application節點。 你可以以組合方式指定這些屬性——例如, EntryPoint、 RuntimeBehavior 和 TrustLevel 有重疊的意義,且它們是以組合方式指定(和/或繼承)。 以下是啟用資訊屬性的一些有效組合。
- Executable, uap10:RuntimeBehavior=“packagedClassicApp”, uap10:TrustLevel=[“mediumIL”, 或 “appContainer”(若省略則為預設) ]
- Executable, uap10:RuntimeBehavior=“win32App”, uap10:TrustLevel=“mediumIL”(其他需求請參見本主題前述的 uap10:RuntimeBehavior 說明)。
- Executable, EntryPoint=“windows.fullTrustApplication” (等同於 uap10:RuntimeBehavior=“packagedClassicApp”, uap10:TrustLevel=“mediumIL”)
- Executable, EntryPoint=“windows.partialTrustApplication” (等同於 uap10:RuntimeBehavior=“packagedClassicApp”, uap10:TrustLevel=“appContainer”)
- Executable, EntryPoint=“<anything else>”
如你所見,如果你的目標系統不支援命名 uap10 空間,你可以指定 EntryPoint 屬性。 同樣地,舊系統上相當於 uap10:TrustLevel=“appContainer”' 的 EntryPoint=“windows.partialTrustApplication”。
但同時指定 uap10:RuntimeBehavior/、uap10:TrustLevel 和 EntryPoint 是多餘的。 但是,如果你這樣做,那麼如果他們相互矛盾,這是一個錯誤。
通用 Windows 平台 (UWP) 應用程式啟用需要 EntryPoint。 所以如果你指定 Executable 和 uap10:RuntimeBehavior=“windowsApp”(沒有 EntryPoint),那就是錯誤。 在同一情況下, EntryPoint 會指定「windows.fullTrustApplication」和「windows.partialTrustApplication」以外的名稱;而除了這兩個值外,已經和 uap10:RuntimeBehavior=“windowsApp” 一樣。 所以 uap10:RuntimeBehavior 在這種情況下會是多餘的,你只需要指定 Executable 和 EntryPoint。
不支援設定 uap10:RuntimeBehavior=“win32App” 和 uap10:TrustLevel=“appContainer”。
將 uap10:TrustLevel="mediumIL" 設為 uap10:RuntimeBehavior="windowsApp" 需要啟用 Microsoft.coreAppActivation_8wekyb3d8bbwe 自訂功能。
若 uap10:TrustLevel="mediumIL" 且 EntryPoint 是任何非 "windows.fullTrustApplication" 或 "windows.partialTrustApplication"的值,這也同樣成立。
你可以在「 自訂能力」一節閱讀更多關於此自訂能力的資訊。
多重實例應用程式的重要注意事項
- 如果應用程式在元素中宣告 Application,那麼所有前景擴充也會是多重實例。
- 如果應用程式在元素Application中宣告 SupportsMultipleInstances,則不需要在該Extensions層級宣告(例如在 BackgroundTasks 或 AppService 元素中)。
- 應用程式應該只在背景任務、背景音訊或應用程式服務上宣告 SupportsMultipleInstances 。
- 主控台應用程式永遠是多實例,必須明確宣告 SupportsMultipleInstances。
- 應用程式可以使用清單中的 ResourceGroup 宣告,將多個背景任務分組到同一主機。 這與多重例項衝突,其中每次啟動都會進入不同的主機。 因此,應用程式無法在清單中同時宣告 SupportsMultipleInstances 與 ResourceGroup 。
如需更多關於使用 SupportsMultipleInstances 屬性來支援多個獨立的 UWP 應用程式實例的資訊,請參見 Create a multi-instance Universal Windows 應用程式。