Skip to content

Fix PowerShell cmdlets running winget.exe from the current directory - #6684

Open
AmirMS (AmelBawa-msft) wants to merge 7 commits into
microsoft:masterfrom
AmelBawa-msft:user/amelbawa/fix-winget-wrapper-resolution
Open

AmirMS (AmelBawa-msft) wants to merge 7 commits into
microsoft:masterfrom
AmelBawa-msft:user/amelbawa/fix-winget-wrapper-resolution

Conversation

@AmelBawa-msft

@AmelBawa-msft AmirMS (AmelBawa-msft) commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

Resolve WinGet for Assert-WinGetPackageManager and Repair-WinGetPackageManager from the Microsoft-published, Store-signed App Installer package instead of CWD/PATH. Preserve PATH/alias checks and consistent PATH repair; development builds keep the wingetdev alias.

🔗 References

🔍 Validation

🤖 AI Assistance

  • AI assistance was used and has been disclosed in this PR
  • No AI assistance was used

AI assisted with the package-based implementation, regression tests, local validation and this description.

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The diagnostic retry can execute an unsafe current-directory WinGet executable after safe resolution rejects it, while quoted absolute PATH entries are incorrectly ignored.

2 open issues
What changed in this PR

This PR updates the PowerShell client engine to resolve winget.exe explicitly from PATH rather than relying on process lookup that also searches the current directory.

Changes:

  • Searches fully qualified PATH entries and reports file-not-found when no match exists.
  • Adds tests for PATH ordering and rejection of current-directory-relative entries.
  • Adds a release note for the affected PowerShell cmdlets.
File Description
src/​PowerShell/​Microsoft.WinGet.UnitTests/​WingetCLIWrapperTests.cs Tests first-match selection and rejection of relative PATH entries.
src/​PowerShell/​Microsoft.WinGet.Client.Engine/​Helpers/​WingetCLIWrapper.cs Adds explicit PATH resolution before launching WinGet.
doc/​release-notes/​1.31/​powershell-winget-path-resolution.md Documents the fix for assert and repair cmdlets.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The absolute-path launch bypasses PATH and app-execution alias checks, allowing Repair to report success while PATH remains broken or an alias remains disabled.

1 open issue
2 resolved since last review

Review effort: Balanced

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The security-sensitive executable-selection change needs human confirmation that the reported Windows checks cover this exact diff, since the PR description ties validation to an uncommitted follow-up.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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.

3 participants