Note the restricted capability required to use the PackageManager API - #481
Note the restricted capability required to use the PackageManager API#481Roy (RDMacLachlan) wants to merge 1 commit into
Conversation
The PackageManager (Windows.Management.Deployment) references in these conceptual topics didn't mention that the calling app must declare the appropriate restricted capability, or link to the capability declarations page. Add capability notes that distinguish install from query: - msix-server-2019.md: installing via the Package Manager API requires the `packageManagement` restricted capability - app-installer/app-installer-documentation.md: the AddPackageByAppInstaller- FileAsync / RequestAddPackageByAppInstallerFileAsync methods require the `packageManagement` restricted capability - package/package-folding.md: querying packages your app didn't author with the PackageManager class requires the `packageQuery` restricted capability Each note links to the restricted capability declarations reference and the package manifest, and clarifies that managing/querying your own app's packages doesn't require the capability. Bump ms.date on the edited files. Resolves AB#25736442 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Learn Build status updates of commit b6d2729: ✅ Validation status: passed
For more details, please refer to the build report. |
| The [PackageManager](/uwp/api/windows.management.deployment.packagemanager) and [Package](/uwp/api/windows.applicationmodel.package) classes in the Windows SDK provide methods you can use to add or modify packages via App Installer files, or to retrieve information about apps with an App Installer association. | ||
|
|
||
| > [!NOTE] | ||
| > To add packages with the `AddPackageByAppInstallerFileAsync` or `RequestAddPackageByAppInstallerFileAsync` methods, the calling app must declare the `packageManagement` [restricted capability](/windows/uwp/packaging/app-capability-declarations#restricted-capabilities) in its [package manifest](/uwp/schemas/appxpackage/appx-package-manifest). This is required for cross-publisher scenarios; managing your own app's packages works without declaring the capability. |
There was a problem hiding this comment.
Is this only required for processes running in an AppContainer?
Or Centennial processes on older Windows (before 24H2/Ge)? There used to be a restriction eg. pkgmgr.AddPackage*() required the caller...
- ...has admin privilege (the ultimate Yes Sir! Right away Sir!)
- ...is in an AppContainer and has the packageManagement capability
- ...is unpackaged and MediumIL
- ...is Centennial and target package's publisher == caller's publisher
Notice #4 vs #3. If you're MediumIL and you target a package by Publisher=Contoso you FAILED if you were packaged/Centennial and SUCCEEDED if you were unpackaged (I don't recall the outcome if caller was Win32alacarte). Yes, a weird (very asymmetric) rule to penalize some types of packaged processes. But we lifted this restriction in 24H2 (Ge), replacing #3+4 with the new rule "...is MediumIL"
That makes the new rules as of >=24H2
- ...is in an AppContainer and has the packageManagement capability
- ...is IntegrityLevel >= Medium
Please check with the team re the PackageManager.AppInstaller() API requirements (present and past).
Resolves the doc bug asking that the PackageManager API references note the appropriate restricted capability and link to the capability declarations page (AB#25736442).
What changed
The literal API reference page (
/uwp/api/...PackageManager) lives in the winrt-api repo, but several conceptual topics here reference the PackageManager API for install/query without noting the required restricted capability. This adds notes that follow the same pattern already used innon-store-developer-updates.md, distinguishing install from query (per the reporter's own guidance on the bug):packageManagementrestricted capabilityAddPackageByAppInstallerFileAsync/RequestAddPackageByAppInstallerFileAsyncmethods require thepackageManagementrestricted capabilitypackageQueryrestricted capabilityEach note links to the restricted capability declarations reference and the package manifest, and clarifies that managing/querying your own app's packages doesn't require the capability.
ms.datebumped on the edited files.