Skip to content

Commit 61d6fcf

Browse files
committed
Workaround for 0x80073D02 when installing with dependencies
1 parent b79e373 commit 61d6fcf

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

FluentStore.SDK/Helpers/PackagedInstallerHelper.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static async Task<bool> IsInstalled(string packageFamilyName)
8888
}
8989

9090
/// <inheritdoc cref="PackageBase.InstallAsync"/>
91-
public static async Task<bool> Install(PackageBase package)
91+
public static async Task<bool> Install(PackageBase package, bool installDependencies = true)
9292
{
9393
try
9494
{
@@ -114,13 +114,13 @@ void InstallProgress(DeploymentProgress p)
114114
else
115115
{
116116
IEnumerable<Uri> dependencies = null;
117-
if (package is IHasDependencies packageWithDependencies)
117+
if (package is IHasDependencies packageWithDependencies && installDependencies)
118118
dependencies = packageWithDependencies.DependencyDownloadItems?.Select(f => new Uri(f.FullName)).ToArray();
119119

120120
operation = pkgManager.AddPackageAsync(
121121
new Uri(package.DownloadItem.FullName),
122122
dependencies,
123-
DeploymentOptions.None);
123+
DeploymentOptions.ForceTargetApplicationShutdown);
124124
}
125125

126126
var result = await operation.AsTask(new Progress<DeploymentProgress>(InstallProgress));
@@ -138,6 +138,14 @@ void InstallProgress(DeploymentProgress p)
138138
}
139139
catch (Exception ex)
140140
{
141+
// "The package could not be installed because resources it modifies are currently in use."
142+
// We've configured the install operation to close the main app if necessary, so this means
143+
// some dependencies must already be installed. Retry the install, without dependencies.
144+
if ((uint)ex.HResult is 0x80073D02)
145+
{
146+
return await Install(package, false);
147+
}
148+
141149
WeakReferenceMessenger.Default.Send(new ErrorMessage(ex, package, ErrorType.PackageInstallFailed));
142150
return false;
143151
}

0 commit comments

Comments
 (0)