PackageRuntimeManager.RemovePackageSet(PackageSetRuntimeDisposition) 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.
public:
virtual void RemovePackageSet(PackageSetRuntimeDisposition ^ packageSetRuntimeDisposition) = RemovePackageSet;
void RemovePackageSet(PackageSetRuntimeDisposition const& packageSetRuntimeDisposition);
public void RemovePackageSet(PackageSetRuntimeDisposition packageSetRuntimeDisposition);
function removePackageSet(packageSetRuntimeDisposition)
Public Sub RemovePackageSet (packageSetRuntimeDisposition As PackageSetRuntimeDisposition)
Parameters
- packageSetRuntimeDisposition
- PackageSetRuntimeDisposition
Examples
A Fabrikam app uses Contoso's Example1 and Example2 packages via Dynamic Dependencies; installing them if necessary. These packages are added to the package graph, and later removed when no longer needed.
void DoWorkWithExample1AndExample2()
{
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);
DoWork();
packageRuntimeManager.RemovePackageSet(packageSetRuntimeDisposition);
}
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)
};