Skip to content

Note the restricted capability required to use the PackageManager API - #481

Open
Roy (RDMacLachlan) wants to merge 1 commit into
MicrosoftDocs:mainfrom
RDMacLachlan:users/romaclac/docbug-25736442
Open

Note the restricted capability required to use the PackageManager API#481
Roy (RDMacLachlan) wants to merge 1 commit into
MicrosoftDocs:mainfrom
RDMacLachlan:users/romaclac/docbug-25736442

Conversation

@RDMacLachlan

Copy link
Copy Markdown
Collaborator

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 in non-store-developer-updates.md, distinguishing install from query (per the reporter's own guidance on the bug):

  • msix-server-2019.md — installing via the Package Manager API requires the packageManagement restricted capability
  • app-installer/app-installer-documentation.md — the AddPackageByAppInstallerFileAsync / 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. ms.date bumped on the edited files.

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-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit b6d2729:

✅ Validation status: passed

File Status Preview URL Details
msix-src/app-installer/app-installer-documentation.md ✅Succeeded
msix-src/msix-server-2019.md ✅Succeeded
msix-src/package/package-folding.md ✅Succeeded

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

  1. ...has admin privilege (the ultimate Yes Sir! Right away Sir!)
  2. ...is in an AppContainer and has the packageManagement capability
  3. ...is unpackaged and MediumIL
  4. ...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

  1. ...is in an AppContainer and has the packageManagement capability
  2. ...is IntegrityLevel >= Medium

Please check with the team re the PackageManager.AppInstaller() API requirements (present and past).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants