PackageDeploymentManager.AddPackageByUriAsync(Uri, AddPackageOptions) Method

Definition

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

public:
 virtual IAsyncOperationWithProgress<PackageDeploymentResult ^, PackageDeploymentProgress> ^ AddPackageByUriAsync(Uri ^ packageUri, AddPackageOptions ^ options) = AddPackageByUriAsync;
IAsyncOperationWithProgress<PackageDeploymentResult, PackageDeploymentProgress> AddPackageByUriAsync(Uri const& packageUri, AddPackageOptions const& options);
public IAsyncOperationWithProgress<PackageDeploymentResult,PackageDeploymentProgress> AddPackageByUriAsync(System.Uri packageUri, AddPackageOptions options);
function addPackageByUriAsync(packageUri, options)
Public Function AddPackageByUriAsync (packageUri As Uri, options As AddPackageOptions) As IAsyncOperationWithProgress(Of PackageDeploymentResult, PackageDeploymentProgress)

Parameters

packageUri
Uri Uri

The URI of the package to add. The URI can use the file URI scheme (file://) for local file paths and local network paths. HTTP and HTTPS protocols are also supported. Starting with Windows build 22556, The URI can point to a package or an App Installer file.

options
AddPackageOptions

The package deployment options for the operation.

Returns

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

Examples

A Fabrikam app installing Contoso's Example package from an https: source.

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

Remarks

  • You can use the ExternalLocationURI property of the options parameter to specify the URI of an external disk location outside of the MSIX package where the package manifest can reference application content. For more information about this scenario and a related code sample, see Grant package identity by packaging with external location.

  • You can use the AllowUnsigned property of the options parameter to allow activation information from an executable in an unsigned package.

Applies to

See also