powertoys: Refactor installation & uninstallation logic#17104
powertoys: Refactor installation & uninstallation logic#17104SorYoshino wants to merge 2 commits intoScoopInstaller:masterfrom
Conversation
* Update notes field * Update checkver & autoupdate * Improve shell extension management
WalkthroughUpdated the PowerToys manifest and scripts: license field normalized to an object, installer extraction logic revamped with engine-version branching and cleanup, unified post-install registry/script placeholder handling, added an uninstaller block with registry/Appx cleanup, and tightened Appx/checkver/autoupdate asset selection. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Installer as Installer Script
participant FSys as File System
participant Manifest as manifest.xml
participant Registry
participant Appx as Appx Engine
User->>Installer: Run installation
Installer->>FSys: Extract archive to temp (generic path)
Installer->>FSys: Locate MSI within extracted contents
Installer->>Manifest: Read engine version
alt Engine >= 5.0
Installer->>FSys: Extract MSI to version-specific directory
else Legacy Engine
Installer->>FSys: Extract MSI to legacy directory
end
Installer->>Registry: Compute powertoys_dir and registry_scope
Installer->>Registry: Create or set registry defaults and placeholders
Installer->>Appx: Add/import Appx packages (if present)
Installer->>FSys: Cleanup temporary artifacts
Installer->>User: Installation complete
sequenceDiagram
participant User
participant Uninstaller as Uninstaller Script
participant Registry
participant Appx as Appx Engine
participant FSys as File System
User->>Uninstaller: Run uninstallation
Uninstaller->>Registry: Determine registry scope and powertoys entry
Uninstaller->>Appx: Query matching Appx packages by name pattern
Uninstaller->>Appx: Remove matching Appx packages
alt Uninstall Flag Set
Uninstaller->>Registry: Remove PowerToys registry keys and CLSIDs
else Keep Installation
Uninstaller->>Registry: Reset registry default values
end
Uninstaller->>FSys: Stop explorer (with delay)
Uninstaller->>User: Uninstallation complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
All changes look good. Wait for review from human collaborators. powertoys
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@scripts/powertoys/uninstall-context.ps1`:
- Around line 35-37: The loop using ForEach-Object currently relies on nested $_
which causes the inner Where-Object $_ to shadow the outer iterator
(ForEach-Object) and match every package; fix by capturing the outer value into
a named variable (e.g., $feature or $pattern) before calling Get-AppxPackage,
then use that named variable inside the Where-Object scriptblock to compare
PackageFullName (so Get-AppxPackage | Where-Object { $_.PackageFullName -like
"*$pattern*" } | Remove-AppxPackage) ensuring only packages matching the
intended feature names are removed; update references to $_ accordingly in the
ForEach-Object, Where-Object, and Remove-AppxPackage pipeline.
🧹 Nitpick comments (3)
scripts/powertoys/install-context.ps1 (1)
10-21: Consider guarding component key creation.The
componentssubkey is always recreated with-Force, which is acceptable. However, for consistency with lines 1-8, you could add a similarTest-Pathguard to avoid unnecessary recreation.bucket/powertoys.json (2)
27-38: Consider error handling for missing manifest.xml.If
manifest.xmlis missing or malformed, the XML parsing on line 31 or version extraction on line 32 will fail. The script may throw an error rather than gracefully falling back.♻️ Proposed defensive check
"Expand-DarkArchive -Path \"$dir\\$fname\" -DestinationPath \"$dir\\tmp\" -Removal", "$installer_file = Get-ChildItem -Path \"$dir\\tmp\\AttachedContainer\" -Filter '*.msi' -File", - "[xml]$xml = Get-Content -Path \"$dir\\tmp\\UX\\manifest.xml\" -Encoding utf8", - "$engine_version = $xml.BurnManifest.EngineVersion", - "if ($null -ne $engine_version -and [version]$engine_version -ge [version]::new(5, 0)) {", + "$manifest_path = \"$dir\\tmp\\UX\\manifest.xml\"", + "$engine_version = $null", + "if (Test-Path -Path $manifest_path) {", + " [xml]$xml = Get-Content -Path $manifest_path -Encoding utf8", + " $engine_version = $xml.BurnManifest.EngineVersion", + "}", + "if ($null -ne $engine_version -and [version]$engine_version -ge [version]::new(5, 0)) {",
77-78: Explorer restart impacts user experience.Stopping
explorer.execloses all open File Explorer windows and temporarily removes the taskbar. While necessary to release shell extension DLLs, consider warning users in the notes or adding a confirmation. The 1500ms delay is reasonable for explorer restart.
|
/verify |
|
All changes look good. Wait for review from human collaborators. powertoys
|
Summary
Refactors the
powertoysmanifest and associated scripts to improve installation reliability, shell extension (context menu) management, and registry state validation.Related issues or pull requests
Changes
licensefield with explicit SPDX identifier and source URL.installerlogic to use[version]type checking and improvedExpand-DarkArchiveparameters.post_installanduninstallerscripts with robust registry value validation (checking for specific protocol strings/status markers) before performing actions.{{scoop_dir}}to{{powertoys_dir}}) and using UTF-8 encoding for file operations.explorerrestart and sleep delay in theuninstallerto ensure shell extensions are properly released.checkverto use repository ID, filter out pre-releases, and utilize a more precise regex for asset detection.autoupdateregex to handle diverse HTML structures on the release page.Notes
HKCU:\Software\Classes\powertoysto create values such asAllowDataDiagnosticsandDataDiagnosticsViewEnabled.$registry_pathexistsscoop install powertoys, the context menu will always be registered, which may cause confusion for users who are only testing the manifest.Testing
Note
Since I have already installed the machine-wide version of PowerToys via winget, the following tests do not include the context menu registration component in order to avoid unnecessary complications.
The test results are as follows:
<manifest-name[@version]|chore>: <general summary of the pull request>Summary by CodeRabbit
New Features
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.