PackageDeploymentManager.AddPackageSetAsync Method

Definition

public:
 virtual IAsyncOperationWithProgress<PackageDeploymentResult ^, PackageDeploymentProgress> ^ AddPackageSetAsync(PackageSet ^ packageSet, AddPackageOptions ^ options) = AddPackageSetAsync;
IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress> AddPackageSetAsync(PackageSet const& packageSet, AddPackageOptions const& options);
public IAsyncOperationWithProgress<PackageDeploymentResult,PackageDeploymentProgress> AddPackageSetAsync(PackageSet packageSet, AddPackageOptions options);
function addPackageSetAsync(packageSet, options)
Public Function AddPackageSetAsync (packageSet As PackageSet, options As AddPackageOptions) As IAsyncOperationWithProgress(Of PackageDeploymentResult, PackageDeploymentProgress)

Parameters

packageSet
PackageSet

Returns

Examples

AddPackageSetAsync(ps, options) is functionally equivalent to this code example:

var pdm = PackageDeploymentManager().GetDefault();
foreach (PackageSetItem psi in ps.Items)
{
    var result = await pdm.AddPackageAsync(psi.PackageUri, options)
    if (result.Status != PackageDeploymentStatus.CompletedSuccess)
    {
        return result;
    }
}
return new PackageDeploymentResult(PackageDeploymentStatus.CompletedSuccess);

This next example is of a Fabrikam app installing Contoso's Example1 and Example2 packages via a PackageSet.

void Install()
{
    var packageSet = new PackageSet() {
        Items = { new PackageSetItem() { PackageUri = new Uri("c:\\contoso\\example1-1.2.3.4.msix") },
                { new PackageSetItem() { PackageUri = new Uri("https://contoso.com/example2-2.4.6.8.msix") } };

    var packageDeploymentManager = PackageDeploymentManager.GetDefault();
    var options = new AddPackageOptions();
    var deploymentResult = await packageDeploymentManager.AddPackageByUriAsync(packageSet, options);
    if (deplymentResult.Status == PackageDeploymentStatus.CompletedSuccess)
    {
        Console.WriteLine("OK");
    }
    else
    {
        Console.WriteLine("Error:{} ExtendedError:{} {}",
            deploymentResult.Error.HResult, deploymentResult.ExtendedError.HResult, deploymentResult.ErrorText);
    }
}

Applies to