PackageRuntimeManager.AddPackageSet Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AddPackageSet(PackageSet) |
Make the package(s) in the package set available to the calling process. That is, dynamically add the package(s) in the package set to the caller's package graph. |
AddPackageSet(PackageSet, CreatePackageDependencyOptions, AddPackageDependencyOptions) |
AddPackageSet(PackageSet)
Make the package(s) in the package set available to the calling process. That is, dynamically add the package(s) in the package set to the caller's package graph.
public:
virtual PackageSetRuntimeDisposition ^ AddPackageSet(PackageSet ^ packageSet) = AddPackageSet;
/// [Windows.Foundation.Metadata.Overload("AddPackageSet")]
PackageSetRuntimeDisposition AddPackageSet(PackageSet const& packageSet);
[Windows.Foundation.Metadata.Overload("AddPackageSet")]
public PackageSetRuntimeDisposition AddPackageSet(PackageSet packageSet);
function addPackageSet(packageSet)
Public Function AddPackageSet (packageSet As PackageSet) As PackageSetRuntimeDisposition
Parameters
- packageSet
- PackageSet
The package set.
Returns
A PackageSetRuntimeDisposition representing the result of the operation.
- Attributes
Examples
AddPackageSet(ps)
is functionally equivalent to this code example:
var pdm = PackageDeploymentManager().GetDefault();
foreach (PackageSetItem psi in ps.Items)
{
var pd = TryCreatePackageDependency(psi);
if (pd != null)
{
pdm.AddPackageDependency(pd);
}
}
This next example is of a Fabrikam app using Contoso's Example1 and Example2 packages via Dynamic Dependencies; installing them if necessary. These packages are added to the package graph, and not explicitly removed (they stay in the package graph until process termination).
void AddExample1AndExample2ToThePackageGraph()
{
var packageSet = new PackageSet() {
Items = { new PackageSetItem() { PackageFamilyName = "contoso.example1_1234567890abc",
MinVersion = ToVersion(1, 2, 3, 4),
PackageUri = new Uri("c:\\contoso\\example1-1.2.3.4.msix") },
{ new PackageSetItem() { PackageFamilyName = "contoso.example2_1234567890abc",
MinVersion = ToVersion(2, 4, 6, 8),
PackageUri = new Uri("https://contoso.com/example2-2.4.6.8.msix") } };
var packageDeploymentManager = PackageDeploymentManager.GetDefault();
var options = new EnsureReadyOptions();
var deploymentResult = await packageDeploymentManager.EnsurePackageSetReadyAsync(packageSet, options);
if (deplymentResult.Status == PackageDeploymentStatus.CompletedSuccess)
{
Console.WriteLine("OK");
}
else
{
Console.WriteLine("Error:{} ExtendedError:{} {}",
deploymentResult.Error.HResult, deploymentResult.ExtendedError.HResult, deploymentResult.ErrorText);
}
var packageRuntimeManager = PackageRuntimeManager.GetDefault();
var packageSetRuntimeDisposition = packageRuntimeManager.AddPackageSet(packageSet);
}
PackageVersion ToVersion(uint major, uint minor, uint build, uint revision) =>
new PackageVersion {
Major = checked((ushort)major),
Minor = checked((ushort)minor),
Build = checked((ushort)build),
Revision = checked((ushort)revision)
};
Applies to
AddPackageSet(PackageSet, CreatePackageDependencyOptions, AddPackageDependencyOptions)
public:
virtual PackageSetRuntimeDisposition ^ AddPackageSet(PackageSet ^ packageSet, CreatePackageDependencyOptions ^ createOptions, AddPackageDependencyOptions ^ addOptions) = AddPackageSet;
/// [Windows.Foundation.Metadata.Overload("AddPackageSetWithOptions")]
PackageSetRuntimeDisposition AddPackageSet(PackageSet const& packageSet, CreatePackageDependencyOptions const& createOptions, AddPackageDependencyOptions const& addOptions);
[Windows.Foundation.Metadata.Overload("AddPackageSetWithOptions")]
public PackageSetRuntimeDisposition AddPackageSet(PackageSet packageSet, CreatePackageDependencyOptions createOptions, AddPackageDependencyOptions addOptions);
function addPackageSet(packageSet, createOptions, addOptions)
Public Function AddPackageSet (packageSet As PackageSet, createOptions As CreatePackageDependencyOptions, addOptions As AddPackageDependencyOptions) As PackageSetRuntimeDisposition
Parameters
- packageSet
- PackageSet
- createOptions
- CreatePackageDependencyOptions
- addOptions
- AddPackageDependencyOptions
Returns
- Attributes
Examples
See Examples for AddPackageSet(PackageSet).