Jun 15 2020 09:34 PM - edited Jun 16 2020 08:08 AM
We use MSIX for one of our LOB applications at my organization. We recently updated some machines to Windows 10 2004 to test it before rolling it out to the rest of the company. One problem we have noticed is that repeatedly that if we update an MSIX package on these systems and then issue a second update, the second update always fails. The event viewer logs multiple errors, most just being generic "the msix package failed to install", etc. However, there is one peculiar one. We found it under:
Microsoft-Windows-AppXDeploymentServer/Operational
Event Id 497
Error 0x80070002: Opening the Msixvc package from location AppName_x64.msixbundle failed. Please check whether the Msixvc support services are installed.
In addition, this is logged under AppXDeployment - Operational:
Event ID: 302
Failed to start system service: appxsvc with error: 0x8007045B
We could not find any documentation on this error anywhere on MSDN.
To work around this, we have to restart the machine. Afterwards it is able to update the MSIX package.
Is this a known issue with Windows 10 2004?
Can anyone here provide more information or can they provide any suggestions on how to stop this from happening?
Edit:
We also had a user go ahead and update their machine to Windows 10 2004 without notifying us and now they are getting the same problem as well.
Edit #2:
I also left this in the feedback hub in Windows 10; if there are any additional channels that I should use, please let me know.
Jun 02 2021 03:29 AM
Jun 07 2021 05:49 AM - edited Jun 07 2021 05:53 AM
Hi everyone,
If anyone is interested, I have a workaround that I'm currently testing.
So, the idea is to do basically parse your .appinstaller file, download the .msixbundle locally, and launch it. Sure it sucks, but it's the best workaround I could come up with, knowing this crappy bug.
(the idea is - if you download and launch the .msixbundle, it works).
If anyone's interested, I can share the code (it's C#)
You would need to update your code:
protected override async void OnLaunched(LaunchActivatedEventArgs e) {
if (setup_kit_util.has_update_downloaded_locally() && await setup_kit_util.launch_update_kit()) {
Application.Current.Exit();
return;
}
...
}
and somewhere in your code's initialize routine, add this:
await Task.Run(async () => await setup_kit_util.download_update_task());
Best,
John
Jun 07 2021 07:00 AM
Jun 07 2021 07:21 AM
I don't consider parsing appinstaller a good solution, but if you want to use it as a workaround you can use a parser from my repo https://github.com/marcinotorowski/MSIX-Hero/tree/develop/src/Otor.MsixHero.AppInstaller/Entities instead of reinventing the wheel
Jun 07 2021 07:59 PM - edited Jun 07 2021 09:51 PM
I've already done the work.
Parsing is easy - I only need to look for the current version of your kit in the .appinstaller.
Then see if your current version matches that. If it's higher, that means there's a new version on server -- download and install it.
Here's the code:
https://github.com/jtorjo/AppinstallerWorkaround
LATER EDIT: Clearly this only deals with your part of the equation. If you have dependencies that need to be updated, things will get a lot more complicated.
Jun 28 2021 02:35 PM
@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());
}
}
Sep 06 2021 09:16 AM
Oct 08 2021 08:49 AM
Oct 22 2021 04:54 AM - edited Oct 22 2021 04:55 AM
Hello,
This is caused by a bug in the Delivery Optimization subsystem of Windows. I provide an explanation of what seems to be happening and an easy workaround here:
https://github.com/MicrosoftDocs/msix-docs/issues/188#issuecomment-947934682
I've tested the workaround a bit with my own app and it seems to resolve the issues. Auto updates are reliable after this. I hope it helps you all!