PackageDeploymentManager.AddPackageAsync(String, AddPackageOptions) Method

Definition

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

public:
 virtual IAsyncOperationWithProgress<PackageDeploymentResult ^, PackageDeploymentProgress> ^ AddPackageAsync(Platform::String ^ package, AddPackageOptions ^ options) = AddPackageAsync;
IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress> AddPackageAsync(winrt::hstring const& package, AddPackageOptions const& options);
public IAsyncOperationWithProgress<PackageDeploymentResult,PackageDeploymentProgress> AddPackageAsync(string package, AddPackageOptions options);
function addPackageAsync(package, options)
Public Function AddPackageAsync (package As String, options As AddPackageOptions) As IAsyncOperationWithProgress(Of PackageDeploymentResult, PackageDeploymentProgress)

Parameters

package
String

Platform::String

winrt::hstring

The package to add.

options
AddPackageOptions

The deployment options for the package.

Returns

The DeploymentProgress percentage of completion over the entire course of the deployment operation.

Examples

A Fabrikam app installing Contoso's Example package from an .msix file.

void Install()
{
    var package = "d:\\contoso\\example.msix";
    var packageDeploymentManager = PackageDeploymentManager.GetDefault();
    var options = new AddPackageOptions();
    var deploymentResult = await packageDeploymentManager.AddPackageAsync(package, options);
    if (deplymentResult.Status == PackageDeploymentStatus.CompletedSuccess)
    {
        Console.WriteLine("OK");
    }
    else
    {
        Console.WriteLine("Error:{} ExtendedError:{} {}",
            deploymentResult.Error.HResult, deploymentResult.ExtendedError.HResult, deploymentResult.ErrorText);
    }
}

Applies to

See also