PackageManager Class
Provides methods for managing Universal Windows Platform (UWP) packages on a device.
Namespace
Remarks
The PackageManager class allows you to programmatically install, uninstall, update, and query UWP applications. It's primarily used by system services, provisioning tools, and advanced deployment scenarios where direct application lifecycle management is required.
For typical application development, you would not directly use this class. Instead, the Windows Runtime manages package installation and updates through the Store or during OS deployment.
Methods
-
AddPackageAsync(sourceUri, dependencies, flags)Adds a package to the device. This method supports installing a single package and its dependencies.
Parameters
sourceUri(Uri): The URI of the package to install.dependencies(IIterable<Uri>): An iterable collection of URIs for any required dependency packages.flags(AddPackageOptions): Options for adding the package.
Returns
An
IAsyncOperationWithProgress<DeploymentProgress, DeploymentProgress>that completes when the package is added.Example:
var packageUri = new Uri("ms-appx://YourPackage.msix"); var packageManager = new PackageManager(); var result = await packageManager.AddPackageAsync(packageUri, null, DeploymentOptions.None); // Handle result... -
FindPackagesForUser(userSecurityId, packageFullName)Finds packages installed for a specific user. You can filter by package full name.
Parameters
userSecurityId(String): The security identifier (SID) of the user.packageFullName(String): The full name of the package to find (optional).
Returns
An
IVectorView<Package>containing the found packages. -
FindPackages()Finds all packages installed on the device.
Returns
An
IVectorView<Package>containing all installed packages. -
RemovePackageAsync(packageFullName)Removes a package from the device.
Parameters
packageFullName(String): The full name of the package to remove.
Returns
An
IAsyncOperationWithProgress<DeploymentProgress, DeploymentProgress>that completes when the package is removed.Example:
var packageManager = new PackageManager(); await packageManager.RemovePackageAsync("YourPackage.YourPublisher.1.0.0.0"); -
StagePackageAsync(sourceUri, dependencyUris, deploymentOptions)Stages a package. This downloads and unpacks the package but does not register it for use. Useful for pre-staging updates.
Parameters
sourceUri(Uri): The URI of the package to stage.dependencyUris(IIterable<Uri>): An iterable collection of URIs for any required dependency packages.deploymentOptions(StagePackageOptions): Options for staging the package.
Returns
An
IAsyncOperationWithProgress<DeploymentProgress, DeploymentProgress>that completes when the package is staged. -
UpdatePackageAsync(updateUri, targetPackageFullName, deploymentOptions)Updates an existing package with a new version.
Parameters
updateUri(Uri): The URI of the updated package.targetPackageFullName(String): The full name of the package to be updated.deploymentOptions(UpdatePackageOptions): Options for updating the package.
Returns
An
IAsyncOperationWithProgress<DeploymentProgress, DeploymentProgress>that completes when the package is updated.
Properties
This class does not expose any public properties directly, but its methods operate on package information obtained through other APIs.