Skip to content

Fix: Prevent reinstallation of already installed versions during upgrade #5490

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kenxpx
Copy link

@Kenxpx Kenxpx commented May 29, 2025

This PR fixes an issue where winget upgrade would show packages for upgrade even when the exact version was already installed.

Problem

If multiple versions of a package are installed (e.g., via different channels), winget upgrade doesn't correctly match all installed versions. It may show an upgrade even if a matching version is already installed.

Fix

This fix iterates over all installed versions and uses the first one that matches the available version and channel. If a match is found, it skips the reinstallation.

Impact

Prevents redundant upgrade suggestions and improves reliability of winget upgrade.

Fixes #2960

Microsoft Reviewers: Open in CodeFlow

@Kenxpx
Copy link
Author

Kenxpx commented May 29, 2025

@microsoft-github-policy-service agree

Copy link
Contributor

@yao-msft yao-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt this change will affect winget upgrade behavior. The code being touched was only used for COM api reporting of a specific installed package version, it was never used in any winget upgrade flow.

Btw, the pr needs some cleanup as it's removing a bunch of comments not related to the change itself.

And if we are fixing incorrect behavior, please add an e2e test (install 2 different versions, and call winget upgrade to verify the correct behavior).

nit: Also the issue linked in pr description points to a winget pre-release, did you type the wrong issue number?

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback Issue needs attention from issue or PR author label May 30, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the No-Recent-Activity Issue has no recent activity label Jun 11, 2025
Copy link
Contributor

Hello @@Kenxpx,

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

Template: msftbot/noRecentActivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Author-Feedback Issue needs attention from issue or PR author No-Recent-Activity Issue has no recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants