Skip to content

Respect -WhatIf in PowerShell package commands - #6588

Open
Slai.life (huong8373tt-beep) wants to merge 3 commits into
microsoft:masterfrom
huong8373tt-beep:fix/powershell-whatif
Open

Slai.life (huong8373tt-beep) wants to merge 3 commits into
microsoft:masterfrom
huong8373tt-beep:fix/powershell-whatif

Conversation

@huong8373tt-beep

@huong8373tt-beep Slai.life (huong8373tt-beep) commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

Fixes #4622.

Package commands run their work on an MTA thread. The existing PowerShellCmdlet.ShouldProcess implementation returned true from that thread instead of evaluating PowerShell's PSCmdlet.ShouldProcess, so -WhatIf could permit real package operations.

Dispatch the decision through the existing PowerShell-thread bridge and return the actual ShouldProcess result. Add regression coverage for install, update, uninstall, MSIX repair, and export. Add a release note.

🔗 References

Fixes #4622

🔍 Validation

  • Built the baseline Microsoft.WinGet.Client.Engine from 3d9083c062c1e7a7086e05becb414d4e005e4ab6 and ran an isolated A/B control against the same local source and test package.
    • Baseline Install-WinGetPackage -WhatIf returned a result and created one ARP entry.
    • The candidate returned no result and created no ARP entry.
    • The candidate engine assembly was restored after the control run.
  • Ran isolated state checks for the candidate:
    • Install: no ARP entry.
    • Update and uninstall: installed version remained unchanged.
    • Export: no download directory.
    • MSIX repair: PackageFullName remained unchanged.
  • The five added Pester tests passed in the local client-suite run.
  • The full manually staged client suite was not clean: 61/70 passed; 9 unrelated EXE cleanup/source-priority cases failed in the local staging setup. This draft does not claim the full suite is green.
  • git diff --check and git show --check passed.

✅ Checklist

🤖 AI Assistance

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

Slai Agent Runtime assisted with analysis, reproduction, implementation, and test execution. The account owner reviewed the reproduction and proposed fix, authorized this contribution, and is responsible for this submission.

📋 Issue Type

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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@JohnMcPMS

Copy link
Copy Markdown
Member

This is an important step, but I suspect that "ShouldProcess" support could use a lot of improvement throughout. I would be willing to take this by itself though.

@huong8373tt-beep
Slai.life (huong8373tt-beep) marked this pull request as ready for review October 21, 2026 19:14
@huong8373tt-beep
Slai.life (huong8373tt-beep) requested a review from a team as a code owner October 21, 2026 19:14
JohnMcPMS
JohnMcPMS previously approved these changes Oct 22, 2026
@JohnMcPMS

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

I checked the approved-head CI failures. The changed PowerShell client Pester set completed with 70 passed / 0 failed. The 53 failures come from Microsoft.WinGet.Configuration.Tests.ps1 after DSCv3 acquisition failed with 0x80244007; the same dependency-install error also appears in the x64 E2E configuration failures, followed by the missing CleanupGroupPolicies helper. None of the failing Configuration/E2E files are changed by this PR, so this looks like an agent or dependency-acquisition failure rather than a regression in the -WhatIf change.

@github-actions

This comment has been minimized.

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.

Update-WinGetPackage -WhatIf: Installs the update instead of saying what it would do

2 participants