I'm working on a Windows desktop application using Blazor MAUI. I'm using the PackageManager class to handle application updates. My current implementation works fine when updating to a newer version, but I'm facing issues when trying to update to an older version than the one that is already installed.
Here is the method I am currently using:
RegisterApplicationRestart(null, RestartFlags.NONE);var deploymentOperation = packageManager.AddPackageAsync(packageUri, null, DeploymentOptions.ForceApplicationShutdown);var opCompletedEvent = new TaskCompletionSource<bool>();deploymentOperation.Completed = (depProgress, status) => opCompletedEvent.SetResult(true);await opCompletedEvent.Task;if (deploymentOperation.Status == AsyncStatus.Error){ var deploymentResult = deploymentOperation.GetResults(); _logger.LogError("Error installing update: {ErrorText}", deploymentResult.ErrorText); returnValue = 1;}else if (deploymentOperation.Status == AsyncStatus.Completed){ _logger.LogInformation("Update installation succeeded.");}When attempting to install an older version of the application than the currently installed version, the update fails. The PackageManager.AddPackageAsync operation does not succeed, and I receive an error indicating that a downgrade is not allowed.
How can I modify my update logic to allow for downgrading to an older version of the application using PackageManager? Are there any specific DeploymentOptions or additional steps I need to take to handle this scenario?
Additional Information:
The application is built using .NET MAUI for Windows.The update packages are downloaded from a remote server.I am using DeploymentOptions.ForceApplicationShutdown in the update operation.Any guidance or examples on handling downgrades would be greatly appreciated.