AddPackageAsync(Uri, IIterable(Uri), DeploymentOptions) | addPackageAsync(Uri, IIterable(Uri), DeploymentOptions) method

PackageManager.AddPackageAsync(Uri, IIterable(Uri), DeploymentOptions) | addPackageAsync(Uri, IIterable(Uri), DeploymentOptions) method

Adds a package (the main package) and its dependency packages for the current user, using the specified deployment options.


IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress>^ AddPackageAsync(
  Uri^ packageUri, 
  IIterable<Uri^>^ dependencyPackageUris, 
  DeploymentOptions deploymentOptions



Type: Windows.Foundation.Uri [JavaScript] | System.Uri [.NET] | Windows::Foundation::Uri [C++]

The Uri of the package to add. The URI must follow the file URI scheme (file://) since the only supported URI schemes are local file paths and local network paths.


Type: IIterable<Uri> [JavaScript/C++] | System.Collections.Generic.IEnumerable<Uri> [.NET]

The Uris of the dependency packages to add. If there are no dependency packages or if the dependency packages are already registered, this parameter can be null.


Type: DeploymentOptions

A bitwise combination of enumeration values from the DeploymentOptions enumeration. ForceApplicationShutdown and None are the only valid options for this method. Specifying any other option results in an E_INVALIDARG return value.

Return value

Type: IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress>

The status of the deployment request. The DeploymentResult contains the final returned value of the deployment operation, once it is completed. The DeploymentProgress can be used to obtain the percentage of completion over the entire course of the deployment operation.


The following example uses the PackageManager.AddPackageAsync method to install a package that has no dependencies or whose dependencies are already installed. Note that the path of the main package is passed as an argument in the example. AddPackageAsync returns an object that can be used to manage the asynchronous operation. The example uses the Completed property to set the delegate and checks the Status property to determine the status of the deployment operation. If the status is Error, the example calls the GetResults method to get additional error information.

using namespace Windows::Foundation;
using namespace Windows::Management::Deployment;

int __cdecl main(Platform::Array<String^>^ args)
    String^ inputPackageUri = args[1];
    int returnValue=0;

    Uri^ packageUri = ref new Uri(inputPackageUri);

    PackageManager^ packageManager = ref new PackageManager();

    auto deploymentOperation = packageManager->AddPackageAsync(

    DeploymentResult^ deploymentOperationResult;

    // This event is signaled when the operation completes
    opCompletedEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

    // Define the delegate
    deploymentOperation->Completed = 
        ref new AsyncOperationWithProgressCompletedHandler<DeploymentResult^, DeploymentProgress>(
        [&](IAsyncOperationWithProgress<DeploymentResult^, DeploymentProgress>^ operation, AsyncStatus)

    // Wait until the operation completes
    WaitForSingleObject(opCompletedEvent, INFINITE);

    // Check the status of the operation
    if ( deploymentOperation->Status == AsyncStatus::Error )
        auto deploymentResult = deploymentOperation->GetResults();
        wcout << L"Error code: " << deploymentOperation->ErrorCode.Value << endl;
        wcout << L"Error text: " << deploymentResult->ErrorText->Data() << endl;
        returnValue = 1;
    else if ( deploymentOperation->Status == AsyncStatus::Canceled )
        wcout << L"Installation canceled" << endl;
    else if ( deploymentOperation->Status == AsyncStatus::Completed )
        wcout << L"Installation succeeded" << endl;
        wcout << L"Installation status unknown" << endl;
        returnValue = 1;
    return returnValue;

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::Management::Deployment [C++]



See also

Add app package sample
AddPackageAsync(Uri, IIterable(Uri), DeploymentOptions, PackageVolume)



© 2016 Microsoft