Forum Discussion
Windows 10 2004 - MSIX Not Updating -Please check whether the Msixvc support services are installed.
StephenWhiteD3G
A WORKING SOLUTION ("no parsing required") - We also ran into this issue recently within our organization so I coded an asynchronous method to stop and start the Delivery Optimization service before the call to CheckUpdateAvailabilityAsync(). Note - Our application runs under the context of the currently logged in user, therefore we had to set a global policy to allow users in the USERS group to stop and start the service name DoSvc . Additionally, these methods will also allow you to take complete control of leveraging MSIX to check for updates whenever you require, and the app will relaunch post update. It will work from desktop shortcuts, and when an MSIX app is pinned to the taskbar (normally MSIX will not update in these scenarios). I call these methods from a timed event that is configured via app settings per environment.
private async Task CheckForUpdateAsync()
{
if (!string.IsNullOrEmpty(_appSettingsProvider.ApplicationVersion))
{
_logger.Info($"The current installed application version is: {_appSettingsProvider.ApplicationVersion}");
}
_logger.Info("Checking for update...");
try
{
var packageManager = new PackageManager();
var installedPackage = packageManager.FindPackageForUser(string.Empty, Package.Current.Id.FullName);
if (installedPackage != null)
{
var tasks = new List<Task>
{
Task.Run(() => RestartDeliveryOptimizationService())
};
await Task.WhenAll(tasks);
var result = await installedPackage.CheckUpdateAvailabilityAsync();
ProcessPackageResult(result, installedPackage);
}
}
catch (InvalidOperationException ex)
{
_logger.Info("AutoUpdater was unable to determine the installed package, which is typically due to debugging in VisualStudio. " + ex);
}
catch (Exception ex)
{
_logger.Error("An error occurred while checking for the availability of a package update. " + ex);
}
}
/// <summary>
/// Restarts the Delivery Optimization Service to ensure updates succeed. Currently a work around for a known issue. - CM
/// </summary>
private void RestartDeliveryOptimizationService()
{
try
{
var service = new ServiceController("DoSvc");
var timeout = TimeSpan.FromMinutes(1);
if (service.Status != ServiceControllerStatus.Stopped)
{
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
}
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch(Exception ex)
{
_logger.Error("There was a problem starting DoSvc." + ex.InnerException.ToString());
}
}
private void ProcessPackageResult(PackageUpdateAvailabilityResult result, Package installedPackage)
{
try
{
if (result != null && (result.Availability == PackageUpdateAvailability.Available || result.Availability == PackageUpdateAvailability.Required))
{
_logger.Info("A package update is available.");
_timer.Enabled = false;
var appInstallerUri = installedPackage.GetAppInstallerInfo().Uri;
Process.Start($"ms-appinstaller:?source={appInstallerUri}");
Application.Exit();
}
else if (result.Availability == PackageUpdateAvailability.Unknown)
{
_logger.Warn("The package update availability status = Unknown.");
}
else if (result.Availability == PackageUpdateAvailability.Error)
{
_logger.Warn($"The package update availability status = Error. {result.ExtendedError.Message}");
_logger.Warn($"No update information associated with app DisplayName:{installedPackage.DisplayName}, FullName:{Package.Current.Id.FullName}");
}
}
catch(Exception ex)
{
_logger.Error("An error occurred while processing the package update. " + ex);
_logger.Error(ex.Message);
_logger.Error(ex.InnerException.ToString());
}
}