Skip to content

Support winget installing AppInstaller #3377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 10, 2023

Conversation

msftrubengu
Copy link
Contributor

@msftrubengu msftrubengu commented Jun 23, 2023

Change

When winget is updating AppInstaller (aka. itself) via winget install 9NBLGGH4NNS1 -s msstore --force if appears the installation failed but in reality, it got updated successfully.

winget install 9NBLGGH4NNS1 -s msstore --force
Verifying/Requesting package acquisition...
Starting package install...
  ███████████████████████████     90%
Failed to install or upgrade Microsoft Store package. Error code: 0x80073d02

The failure means ERROR_PACKAGES_IN_USE and from my last PR #3299 I believe that error will go away because of --force, but a new one will occur. I need a real AppInstaller package to confirm this but because reasons I cannot build it right now. Regardless, the correct fix it to listen to messages from the lifetime manager.

When the system is updating an app, the app lifetime manager will ask any the app to terminate if its running. It does it by:

  1. Sending a WM_QUERYENDSESSION message to any app window.
  2. Sending a CTRL-C signal.

This means that winget.exe needs to start listening to window messages because there's no real difference between the app lifetime manager and a user doing CTRL-C. This PR creates a hidden window and start the message loop. When WM_QUERYENDSESSION is received, we will ask to cancel any progress (as it currently does with CTRL-C) stating the reason as AppShutdown. By design, we are not going to cancel installations as maybe they get completed before they terminate us. Any other operation will be cancelled.

If the context gets cancelled with an AppShutdown reason while installing AppInstaller we will just set the progress as 100% and be done with it as we are going to get terminated soon.

pie title Progress of AppInstaller installation by winget
    "Real" : 9
    "Fake" : 1
Loading

Validation

I created a new winget test appshutdown command that will verify the window handle is correct and the app shutdown event is signaled. The E2E test will run this command and reregister wingetdev to generate the message as deployment would do. I still need a real AppInstaller package to make sure the flow works as I expect.

Microsoft Reviewers: codeflow:open?pullrequest=#3377

@msftrubengu msftrubengu requested a review from a team as a code owner June 23, 2023 20:00
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@msftrubengu msftrubengu changed the title Appinst update Support winget installing AppInstaller Jun 23, 2023
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@msftrubengu msftrubengu merged commit 7d4f839 into microsoft:master Jul 10, 2023
@msftrubengu msftrubengu deleted the appinst_update branch August 14, 2023 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants