Should TrySilentDownloadAndInstallStorePackageUpdatesAsync relaunch the app?

92 Views Asked by At

I'm testing with a win32 desktop app packaged as MSIX and released through the Microsoft Store. I'm trying to use TrySilentDownloadAndInstallStorePackageUpdatesAsync to update the app, which does seem to work, but quits immediately after the update is installed and doesn't relaunch the app.

The MS documentation seems to suggest that this function would relaunch the app (as suggested by the aptly named function IsNowAGoodTimeToRestartApp): https://learn.microsoft.com/en-us/windows/uwp/packaging/self-install-package-updates

However, that's not what I observe. None of the debug statements following the call seem to hit, so it does seem like it is indeed terminating the app; it's just not relaunching it.

Looking for alternatives, there seems to be an old win32 API named RegisterApplicationRestart: https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-registerapplicationrestart

But it has this caveat: "To prevent cyclical restarts, the system will only restart the application if it has been running for a minimum of 60 seconds."

Which is less than ideal; what we're trying to accomplish is doing a quick check for updates, installing them and relaunching, so on the next run there should be no updates to apply and no further need to restart. Waiting 60 seconds here defeats the purpose of a quick check.

What are the alternatives? Any way to get the app to relaunch after installing a MS Store update?

(As a side note: is there any way to test MS store updates without going through the certification process? It can take hours, which completely kills the write-build-test cycle).

1

There are 1 best solutions below

4
Roy Li - MSFT On

IsNowAGoodTimeToRestartApp method is just a place holder which represents the logic you need to do to check if the app is ready to install updates.

StoreContext.TrySilentDownloadAndInstallStorePackageUpdatesAsync Method will not relaunch the app.