PowerShell Repair enhancements#5711
Merged
AmelBawa-msft merged 11 commits intomicrosoft:masterfrom Jan 13, 2026
Merged
Conversation
Trenly
reviewed
Sep 9, 2025
src/PowerShell/Help/Microsoft.WinGet.Client/Repair-WinGetPackageManager.md
Outdated
Show resolved
Hide resolved
src/PowerShell/Help/Microsoft.WinGet.Client/Repair-WinGetPackageManager.md
Outdated
Show resolved
Hide resolved
src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs
Outdated
Show resolved
Hide resolved
src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs
Outdated
Show resolved
Hide resolved
src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs
Outdated
Show resolved
Hide resolved
src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs
Outdated
Show resolved
Hide resolved
JohnMcPMS
reviewed
Sep 11, 2025
src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs
Outdated
Show resolved
Hide resolved
src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs
Outdated
Show resolved
Hide resolved
src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs
Outdated
Show resolved
Hide resolved
src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs
Outdated
Show resolved
Hide resolved
src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs
Outdated
Show resolved
Hide resolved
JohnMcPMS
reviewed
Sep 29, 2025
| /// <param name="includePrerelease">Include prerelease versions.</param> | ||
| /// <param name="result">The resulting version.</param> | ||
| /// <returns>True if a matching version was found.</returns> | ||
| private static bool TryGetLatestMatchingVersion(IEnumerable<WinGetVersion> versions, string pattern, bool includePrerelease, out WinGetVersion result) |
Member
There was a problem hiding this comment.
Suggested change
| private static bool TryGetLatestMatchingVersion(IEnumerable<WinGetVersion> versions, string pattern, bool includePrerelease, out WinGetVersion result) | |
| private static bool TryGetLatestMatchingVersion(IEnumerable<WinGetVersion> versions, string pattern, bool includePrerelease, out WinGetVersion? result) |
Because you very clearly return a null in some cases. You can annotate with the appropriate attribute to mark it as not null when returning true.
Member
There was a problem hiding this comment.
My intention was that you would use the NotNullWhen attribute and not need the ! inside the conditional.
Member
There was a problem hiding this comment.
You could also remove the ! from the null! in the function now.
Contributor
Author
There was a problem hiding this comment.
My intention was that you would use the NotNullWhen attribute and not need the ! inside the conditional.
Unfortunately, the attribute is not supported in net48 desktop framework. It gives compiler errors when attempting.
Reference:
JohnMcPMS
approved these changes
Jan 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Register AppInstaller when using
AddProvisionPackageAsyncwhich was not registering the package prior to this PR change.Added a "best effort" approach to programmatically attempt to downloading the source2.msix and install it.
Keeping this as-is since the code includes a descriptive message. In my repro, the issue occurred when App Installer was not installed, and the code attempted to invoke winget.exe to check if the application was present.
This is not addressed in this PR. It's unclear which constraints should be relaxed, as the current implementation already attempts to ensure the requested parameters are satisfied. The Force flag is currently used to trigger
ForceTargetApplicationShutdownduring package addition, which appears appropriate. I recommend opening a separate issue to propose and discuss the desired behavior.Added support for leading and trailing wildcard:
1.2.*,1.2*,1.*2.3Related issues:
-Versionfor `Repair-WinGetPackageManager #5704Microsoft Reviewers: Open in CodeFlow