PackageManager.RequestAddPackageAsync Method

Definition

Overloads

RequestAddPackageAsync(Uri, IIterable<Uri>, DeploymentOptions, PackageVolume, IIterable<String>, IIterable<Uri>, IIterable<Uri>)

Requests a SmartScreen check and user verification before installing the app Package(s). This method provides a packageUrisToInstall overload to specify external packages to be staged and registered.

RequestAddPackageAsync(Uri, IIterable<Uri>, DeploymentOptions, PackageVolume, IIterable<String>, IIterable<Uri>)

Requests a SmartScreen check and user verification before installing the app Package(s).

RequestAddPackageAsync(Uri, IIterable<Uri>, DeploymentOptions, PackageVolume, IIterable<String>, IIterable<Uri>, IIterable<Uri>)

Requests a SmartScreen check and user verification before installing the app Package(s). This method provides a packageUrisToInstall overload to specify external packages to be staged and registered.

public:
 virtual IAsyncOperationWithProgress<DeploymentResult ^, DeploymentProgress> ^ RequestAddPackageAsync(Uri ^ packageUri, IIterable<Uri ^> ^ dependencyPackageUris, DeploymentOptions deploymentOptions, PackageVolume ^ targetVolume, IIterable<Platform::String ^> ^ optionalPackageFamilyNames, IIterable<Uri ^> ^ relatedPackageUris, IIterable<Uri ^> ^ packageUrisToInstall) = RequestAddPackageAsync;
/// [Windows.Foundation.Metadata.Overload("RequestAddPackageAndRelatedSetAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> RequestAddPackageAsync(Uri const& packageUri, IIterable<Uri> const& dependencyPackageUris, DeploymentOptions const& deploymentOptions, PackageVolume const& targetVolume, IIterable<winrt::hstring> const& optionalPackageFamilyNames, IIterable<Uri> const& relatedPackageUris, IIterable<Uri> const& packageUrisToInstall);
[Windows.Foundation.Metadata.Overload("RequestAddPackageAndRelatedSetAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<DeploymentResult,DeploymentProgress> RequestAddPackageAsync(System.Uri packageUri, IEnumerable<System.Uri> dependencyPackageUris, DeploymentOptions deploymentOptions, PackageVolume targetVolume, IEnumerable<string> optionalPackageFamilyNames, IEnumerable<System.Uri> relatedPackageUris, IEnumerable<System.Uri> packageUrisToInstall);
function requestAddPackageAsync(packageUri, dependencyPackageUris, deploymentOptions, targetVolume, optionalPackageFamilyNames, relatedPackageUris, packageUrisToInstall)
Public Function RequestAddPackageAsync (packageUri As Uri, dependencyPackageUris As IEnumerable(Of Uri), deploymentOptions As DeploymentOptions, targetVolume As PackageVolume, optionalPackageFamilyNames As IEnumerable(Of String), relatedPackageUris As IEnumerable(Of Uri), packageUrisToInstall As IEnumerable(Of Uri)) As IAsyncOperationWithProgress(Of DeploymentResult, DeploymentProgress)

Parameters

packageUri
Uri Uri

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.

dependencyPackageUris

IIterable<Uri>

IEnumerable<Uri>

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.

deploymentOptions
DeploymentOptions

A valid enumeration value from the DeploymentOptions enumeration.

targetVolume
PackageVolume

The volume that the package is installed to.

optionalPackageFamilyNames

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

Strings that specify the optional package family names from the main bundle to be staged and registered.

relatedPackageUris

IIterable<Uri>

IEnumerable<Uri>

The URIs of additional packages in the main bundle that should be staged and registered.

packageUrisToInstall

IIterable<Uri>

IEnumerable<Uri>

A list of other package URIs to be staged and registered. This can contain paths to external packages to be installed.

Returns

The progress and result of adding the app package.

Attributes

Windows requirements

Device family
Windows 10, version 1803 (introduced in 10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v6.0)

See also

Applies to

RequestAddPackageAsync(Uri, IIterable<Uri>, DeploymentOptions, PackageVolume, IIterable<String>, IIterable<Uri>)

Requests a SmartScreen check and user verification before installing the app Package(s).

public:
 virtual IAsyncOperationWithProgress<DeploymentResult ^, DeploymentProgress> ^ RequestAddPackageAsync(Uri ^ packageUri, IIterable<Uri ^> ^ dependencyPackageUris, DeploymentOptions deploymentOptions, PackageVolume ^ targetVolume, IIterable<Platform::String ^> ^ optionalPackageFamilyNames, IIterable<Uri ^> ^ relatedPackageUris) = RequestAddPackageAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> RequestAddPackageAsync(Uri const& packageUri, IIterable<Uri> const& dependencyPackageUris, DeploymentOptions const& deploymentOptions, PackageVolume const& targetVolume, IIterable<winrt::hstring> const& optionalPackageFamilyNames, IIterable<Uri> const& relatedPackageUris);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<DeploymentResult,DeploymentProgress> RequestAddPackageAsync(System.Uri packageUri, IEnumerable<System.Uri> dependencyPackageUris, DeploymentOptions deploymentOptions, PackageVolume targetVolume, IEnumerable<string> optionalPackageFamilyNames, IEnumerable<System.Uri> relatedPackageUris);
function requestAddPackageAsync(packageUri, dependencyPackageUris, deploymentOptions, targetVolume, optionalPackageFamilyNames, relatedPackageUris)
Public Function RequestAddPackageAsync (packageUri As Uri, dependencyPackageUris As IEnumerable(Of Uri), deploymentOptions As DeploymentOptions, targetVolume As PackageVolume, optionalPackageFamilyNames As IEnumerable(Of String), relatedPackageUris As IEnumerable(Of Uri)) As IAsyncOperationWithProgress(Of DeploymentResult, DeploymentProgress)

Parameters

packageUri
Uri Uri

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.

dependencyPackageUris

IIterable<Uri>

IEnumerable<Uri>

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.

deploymentOptions
DeploymentOptions

A valid enumeration value from the DeploymentOptions enumeration.

targetVolume
PackageVolume

The volume that the package is installed to.

optionalPackageFamilyNames

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

Strings that specify the optional package family names from the main bundle to be staged and registered.

relatedPackageUris

IIterable<Uri>

IEnumerable<Uri>

The URIs of additional packages in the main bundle that should be staged and registered.

Returns

The progress and the result of the app package deployment.

Attributes

Windows requirements

Device family
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v5.0)

Examples

The example demonstrates how to use RequestAddPackageAsync in a UWP app by hooking it up to a button click handler. This will invoke the SmartScreen request UI window.

public async void OnInstallNowClicked(object sender, RoutedEventArgs args)
{
    var packageManager = new PackageManager();
    DeploymentOperation result = await packageManager.RequestAddPackageAsync(
            this.currentPackageUri,
            null /*no dependencies*/,
            DeploymentOptions.None,
            null /*stage to default package volume*/,
            null /*no optional packages*/,
            null /*no external packages*/);

    if (result.ExtendedErrorCode != null)
    {
        if (result.ExtendedErrorCode.HResult == 0x80073d01)
        {
            // SmartScreen blocked the app installation.
        }
        else
        {
            // The app installation failed for another reason.
        }
    }
}

See also

Applies to