Repository navigation
[Settings] Add Settings CLI - #50507
Merged
Muyuan Li (MuyuanMS) merged 18 commits intoOct 8, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
…Settings CLI and Library Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
…t commands Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
…conflict" This reverts commit 02a0f332ce012ec01a7994f18f0ffae765d3d57e.
Remove unsafe backup, restore, and reset commands until their existing settings contracts can be reused correctly. Return command failures through process exit codes, expose effective GPO state, clarify restart semantics, and add signing coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Contributor
Author
|
/azp run |
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Inject the effective GPO state into SettingsCliHelper so tests do not depend on machine policy, and cover forced states. Include CmdNotFound in the module policy mapping. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Map all enabled modules with GPO policy, use a strict persistence path for the CLI, and cover policy overrides and save failures in focused tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
| { | ||
| "advancedpaste" => GpoApi.GetConfiguredAdvancedPasteEnabledValue(), | ||
| "alwaysontop" => GpoApi.GetConfiguredAlwaysOnTopEnabledValue(), | ||
| "autohidecursor" => GpoApi.GetConfiguredAutoHideCursorEnabledValue(), |
| "autohidecursor" => GpoApi.GetConfiguredAutoHideCursorEnabledValue(), | ||
| "awake" => GpoApi.GetConfiguredAwakeEnabledValue(), | ||
| "cmdpal" => GpoApi.GetConfiguredCmdPalEnabledValue(), | ||
| "cmdnotfound" => GpoApi.GetConfiguredCmdNotFoundEnabledValue(), |
| "fancyzones" => GpoApi.GetConfiguredFancyZonesEnabledValue(), | ||
| "filelocksmith" => GpoApi.GetConfiguredFileLocksmithEnabledValue(), | ||
| "findmymouse" => GpoApi.GetConfiguredFindMyMouseEnabledValue(), | ||
| "altwindowcycle" => GpoApi.GetConfiguredAltWindowCycleEnabledValue(), |
| "lightswitch" => GpoApi.GetConfiguredLightSwitchEnabledValue(), | ||
| "mousehighlighter" => GpoApi.GetConfiguredMouseHighlighterEnabledValue(), | ||
| "mousejump" => GpoApi.GetConfiguredMouseJumpEnabledValue(), | ||
| "mousepointercrosshairs" => GpoApi.GetConfiguredMousePointerCrosshairsEnabledValue(), |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3feb5faf-8352-4a5f-a3f0-1136ec506fcd
Boliang Zhang (LegendaryBlair)
marked this pull request as ready for review
September 29, 2026 07:35
Boliang Zhang (LegendaryBlair)
requested a review
from a team
as a code owner
September 29, 2026 07:35
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Muyuan Li (MuyuanMS)
marked this pull request as draft
September 30, 2026 02:18
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ec51f670-ad03-4f5d-89e9-0357957c30e9
Muyuan Li (MuyuanMS)
marked this pull request as ready for review
September 30, 2026 02:53
github-actions
Bot
requested a review
from Jessica Dene Earley-Cha (chatasweetie)
September 30, 2026 02:53
🧭 PR intakeVisual evidence: Not needed — The changed files do not indicate a visible UI change. No visual evidence is expected. Recommendation
✅ Ready for reviewThis PR passed the automated intake checks and is ready for maintainer review. Automated PR intake; PowerToys maintainers make final decisions. |
|
Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event. After this PR is merged, please follow these next steps:
|
Contributor
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
This was referenced Sep 30, 2026
Clint Rutkas (crutkas)
added a commit
that referenced
this pull request
Sep 30, 2026
…SamplePagesExtension (#50917) ## Summary of the Pull Request Fixes an intermittent PowerToys CI failure. The main build sometimes fails while MSIX packaging trims the Command Palette sample extension (`SamplePagesExtension`): ``` Microsoft.NET.ILLink.targets(150,5): error MSB6006: "dotnet.exe" exited with code 57005. Microsoft.NET.ILLink.targets(103,5): error NETSDK1144: Optimizing assemblies for size failed. ``` The fix is one Release-only property in `SamplePagesExtension.csproj`: `TrimmerRemoveSymbols=true`. With it, ILLink doesn't rewrite debug symbols for this trim, so it never loads the native Windows PDB writer that crashes. The trimmed code doesn't change. The only difference is that the trimmed output has no PDBs. This is backlog item **BUILD-8** of the PowerToys speed & quality backlog. ## PR Checklist - [ ] Closes: N/A (backlog item BUILD-8, no GitHub issue) - [x] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected (part of the speed & quality backlog) - [ ] **Tests:** Added/updated and all pass (N/A: build-configuration change only, no product code. Validated with a local trimmed publish, repeated ILLink runs before and after the fix, and PR CI; see below) - [ ] **Localization:** All end-user-facing strings can be localized (N/A: no strings) - [ ] **Dev docs:** Added/updated (N/A) - [ ] **New binaries:** Added on the required places (N/A: no new binaries) - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: N/A ## Detailed Description of the Pull Request / Additional comments ### Root cause In the failing jobs, ILLink (`dotnet.exe`, Microsoft.NET.ILLink.Tasks 10.0.11) dies in its output step while it writes symbols: ``` Fatal error. 0xC0000005 at Mono.Cecil.Pdb.ISymUnmanagedWriter2.Close() at Mono.Cecil.Pdb.SymWriter.Close() at Mono.Cecil.Pdb.NativePdbWriter.Write() at Mono.Linker.CustomSymbolWriter.Write() ... at Mono.Linker.Steps.OutputStep.WriteAssembly(Mono.Cecil.AssemblyDefinition, System.String) ``` - **ILLink runs in every Release CI build.** `SamplePagesExtension.csproj` sets `GenerateAppxPackageOnBuild=true`, and in Release it also sets `PublishTrimmed=true`. MSIX packaging during the solution build publishes the app with `win-$(Platform).pubxml`, so `_RunILLink` trims it. It's the only ILLink invocation in PR CI. - **ILLink rewrites the symbols.** `TrimmerRemoveSymbols` defaults to `false` unless `DebuggerSupport=false`, so ILLink gets `-b` and rewrites the PDB of every assembly it trims. - **Those symbols are Windows PDBs.** `src\Common.Dotnet.props` sets Release `DebugType=pdbonly`. That covers the sample and also `Microsoft.CommandPalette.Extensions.Toolkit`, a `ProjectReference` that's trimmed in the same ILLink run. Mono.Cecil can only write Windows PDBs through the native COM `ISymUnmanagedWriter` (the .NET Framework's DiaSymReader). The access violation happens inside that native `Close()`, so we can't fix it in this repo. We can only stop using that writer. ### Affected builds and frequency I used the public Azure DevOps REST API to scan every build still retained for the **PowerToys CI** pipeline (shine-oss/PowerToys, 2026-08-31 to 2026-09-30), including earlier attempts of retried jobs. Each failure below has the same stack, in the SamplePagesExtension `_RunILLink` step: | Build | Trigger | Queued (UTC) | Failed job | | --- | --- | --- | --- | | [388605](https://dev.azure.com/shine-oss/PowerToys/_build/results?buildId=388605) | `main` (batched CI) | 2026-09-11 | Build Release_x64 | | [389658](https://dev.azure.com/shine-oss/PowerToys/_build/results?buildId=389658) | PR #50843 | 2026-09-28 | Build Release_arm64 | | [389667](https://dev.azure.com/shine-oss/PowerToys/_build/results?buildId=389667) | PR #50186 | 2026-09-28 | Build Release_arm64 | | [389871](https://dev.azure.com/shine-oss/PowerToys/_build/results?buildId=389871) | PR #50507 | 2026-09-30 | Build Release_x64 | | [389888](https://dev.azure.com/shine-oss/PowerToys/_build/results?buildId=389888) | PR #50884 | 2026-09-30 | Build Release_x64 | - **Rate:** 5 of 255 builds (~2%) and 5 of 486 x64/arm64 build jobs (~1%). In the last ~2 weeks (2026-09-14 to 2026-09-30) it was 4 of 196 builds (390 build jobs). PR builds only show up in this project from 2026-09-22, and 4 of those 125 PR builds (~3%) failed this way, all in the last three days. It hits both x64 and arm64 jobs. All five failures used ILLink 10.0.11, and every build I sampled from 2026-09-15 on used .NET SDK 10.0.303, so this isn't a new-toolset regression. The 30 scheduled "PowerToys CI (Caching)" builds had no hits. - **Cost:** A hit fails the whole build job after ~30–34 minutes, and the job has to be re-run. A green build job takes ~53 minutes (median), and the test jobs wait for it. In 4 of the 5 builds, this crash was the job's only error. 389888 also had two unrelated unit-test failures in the same task. ### Fix and why | Option | Result | | --- | --- | | (a) `DebugType=portable` for the sample (preferred, because it would keep symbols) | **Not enough.** The sample's PDB becomes portable, but the same ILLink run still rewrites `Microsoft.CommandPalette.Extensions.Toolkit.pdb` as a Windows PDB (verified locally, see Validation), so the native writer is still used. Switching the Toolkit to portable PDBs would change the symbol format of a shipping CmdPal/SDK binary, which is out of scope here. | | (b) `TrimmerRemoveSymbols=true` (**chosen**) | ILLink runs without `-b`, so it doesn't read or write any symbols and never loads the native writer. The trimmed assemblies are otherwise identical. | | (c) Don't package or trim the sample in CI | Not needed. It would also drop CI coverage of the trimmed, AOT-compatible sample that extension authors copy. | Effects of (b): - The sample's trimmed publish output, and so its MSIX, has no PDBs (locally, the publish folder had none). The WinAppSDK MSIX targets skip `_GenerateAppxSymbolPackage` when the payload has no PDBs, so the sample no longer gets an `.appxsym` (confirmed in PR CI). The sample isn't shipped to users (it's not in the installer). - The untrimmed build output keeps its PDB (`<Platform>\Release\WinUI3Apps\CmdPalExtensions\SamplePagesExtension\SamplePagesExtension.pdb`). That's the PDB CI's "Stage Unique Symbols" step already picks up. - Debug builds don't trim, so the extension-author inner loop is unchanged. The property sits in the existing Release property group, and the repo-wide `DebugType` isn't touched. ### Other projects checked - **ILLink in PR CI:** I grepped every build task log of a green PR build ([389905](https://dev.azure.com/shine-oss/PowerToys/_build/results?buildId=389905)) for ILLink and ILC invocations. That covered x64 and arm64 (main build, BugReportTool, StylesReportTool, the seven "Publish … for Packaging" steps, DSC, and the installer) plus the "Build SDK" job. The only `illink.dll` invocation is SamplePagesExtension, once per platform, and nothing runs ILC. - **Other trimmed or AOT projects:** `Microsoft.CmdPal.Ext.PowerToys`, `Microsoft.CommandPalette.Extensions.Toolkit`, `UITestAutomation`, PowerOCR, PowerDisplay (+CLI), and PowerAccent.UI set `PublishAot` or `PublishTrimmed`. PR CI only builds them and never publishes them, so neither ILLink nor ILC runs. CmdPal UI uses Native AOT only in the release pipeline (`EnableCmdPalAOT=true`). Native AOT trims with ILC, not ILLink/Cecil, so it doesn't use this writer. The release pipeline builds the same solution, so its SamplePagesExtension trim gets this fix too. No follow-ups needed. - **`src\modules\cmdpal\ExtensionTemplate`:** Not built in CI (it's not in `PowerToys.slnx`, and `verifyCommonProps.ps1` skips it). It doesn't import `Common.Dotnet.props` or set `DebugType`, so it uses the SDK default portable PDBs. The Toolkit it gets from NuGet ships without a PDB, so a trimmed template publish only uses Cecil's managed portable-PDB writer. No template change needed. ## Validation Steps Performed **Local environment limits:** The dev box is ARM64 with VS 18 and has no C++ toolset or Windows SDK, so there's no `MakeAppx` and MSIX packaging can't run locally. I exercised ILLink with a Release|x64 publish that skips packaging: ```powershell tools\build\build.ps1 -Platform x64 -Configuration Release /restore /t:Publish /p:GenerateAppxPackageOnBuild=false ` /p:CsWinRTWindowsMetadata=<Microsoft.Windows.SDK.NET.Ref>\winmd ` /p:CustomAfterMicrosoftCommonTargets=<local hook that swaps .vcxproj references for prebuilt winmd/dll> ``` The hook is local only and isn't part of this PR. Restores were anonymous (`NUGET_PLUGIN_PATHS`, `NUGET_NETFX_PLUGIN_PATHS`, and `NUGET_NETCORE_PLUGIN_PATHS` pointed at an empty folder), and no new packages were needed. Local ILLink is 10.0.12 (SDK 10.0.401); CI uses 10.0.11. To tell PDB formats apart, I checked the file header: a Windows PDB starts with `Microsoft C/C++ MSF 7.00` and a portable PDB starts with `BSJB`. 1. **Before (`main`):** Publish exits 0. ILLink runs with `-b` and writes `SamplePagesExtension.pdb` and `Microsoft.CommandPalette.Extensions.Toolkit.pdb` as Windows PDBs, which means the native writer is used. 2. **Option (a), not committed:** `SamplePagesExtension.pdb` becomes portable (`BSJB`), but ILLink still writes `Microsoft.CommandPalette.Extensions.Toolkit.pdb` as a Windows PDB. 3. **After (this PR):** Publish exits 0 with the same two `IL2104` warnings as `main` (both already in `WarningsNotAsErrors`). The ILLink task gets `RemoveSymbols=True`, so there's no `-b`, and it returns `_ILLinkExitCode=0` without writing any PDBs. Compared with the "before" output, the trimmed `SamplePagesExtension.dll` (171 types, 743 methods, 251 fields) and `Microsoft.CommandPalette.Extensions.Toolkit.dll` (399 types, 1850 methods, 530 fields) have the same metadata counts and code size. The only change is the missing CodeView debug-directory entry (the pointer to the PDB). 4. **Property evaluation:** `dotnet msbuild -getProperty` gives `TrimmerRemoveSymbols=true` for Release|x64 and Release|ARM64 and leaves it empty for Debug, where `PublishTrimmed=false`. 5. **Repeated trims:** I replayed the exact ILLink command from the MSBuild log 20 times with the native arm64 `dotnet` and 20 times with the emulated x64 `dotnet` (closer to the x64 CI agents), before and after the fix. - Before: 40/40 passed, plus 10 more runs with `DOTNET_GCgen0size=0x20000`. Every run wrote two Windows PDBs through the native writer. - After: 40/40 passed, and no PDBs were written. - The crash didn't reproduce locally. That's consistent with a ~1% per-job rate, so PR CI is the real gate. 6. **PR CI ([389926](https://dev.azure.com/shine-oss/PowerToys/_build/results?buildId=389926)): green on x64 and arm64.** All jobs passed: Build Release_x64 (build + tests), Build Release_arm64, Build SDK, and both "Resolve affected UI test projects" jobs. In both main-build logs: - SamplePagesExtension's ILLink ran once (`illink.dll -a "obj\x64\Release\SamplePagesExtension.dll"` and `obj\ARM64\...`, ILLink 10.0.11) without `-b`. It has 253 arguments versus 254 in build 389905, which doesn't have this change, and the only one missing is `-b`. - There were no `Fatal error`, `0xC0000005`, `57005`, or `NETSDK1144` markers. The task had 0 errors and the same two `IL2104` warnings as 389905. - MSIX packaging still produced `SamplePagesExtension_1.0.0.0_x64.msix` and `SamplePagesExtension_1.0.0.0_arm64.msix`, and it skipped the sample's `.appxsym` as expected. - "Stage Unique Symbols" still links 202 PDBs per platform, the same as 389905, and that includes the untrimmed `SamplePagesExtension.pdb`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Boliang Zhang (LegendaryBlair)
approved these changes
Oct 8, 2026
2 of 7 tasks
Clint Rutkas (crutkas)
added a commit
that referenced
this pull request
Oct 9, 2026
Light Switch CLI (#50459) and Settings CLI (#50507) merged to main using System.CommandLine beta APIs, breaking the 2.0 GA upgrade build. Port them to the GA API while preserving command names, options, output, and exit codes. Light Switch clears the default RootCommand help/version/directives, ignores implicit option results, and reports leading [directive] tokens as unrecognized to keep the previous parsing behavior.
4 tasks done
Yu Leng (moooyo)
added a commit
that referenced
this pull request
Oct 15, 2026
## Summary of the Pull Request Add `LightSwitch_CLICommand` and `PowerDisplay_CLICommand` using the Settings CLI telemetry pattern, providing a basic usage signal for the two CLIs. Each invocation records an allowlisted `CommandName` and a `Successful` flag based on its final exit code, through the existing diagnostics consent check. Related CLI work: #50459 and #48632. Telemetry pattern: #50507. ## PR Checklist - [x] **Tests:** Existing CLI regression suites pass. - [x] **Localization:** No new user-facing strings. - [x] **Dev docs:** Not applicable to this telemetry-only change. - [x] **New binaries:** No new binaries or external dependencies; ManagedTelemetry was already a transitive dependency. ## Detailed Description of the Pull Request / Additional comments - Wrap execution in `src/modules/LightSwitch/LightSwitch.Cli/Program.cs` and `src/modules/powerdisplay/PowerDisplay.Cli/Program.cs` to attempt one event per invocation, including help/version, validation failures, and exceptions. Telemetry failures preserve the command's output, exit code, and exception. - Match Settings CLI's first-token allowlist. Option-first and response-file invocations use `unknown`; raw arguments, monitor IDs, profile values, and file paths are excluded from telemetry. - Enable `EventSourceSupport` in both NativeAOT projects and preserve the event properties for trimming. ## Validation Steps Performed - Repository `build-essentials.ps1`, Debug/x64: exit 0. - Existing CLI regression tests passed with `vstest.console.exe`: LightSwitch **221/221**, PowerDisplay **130/130**. - Publish both CLIs with `tools/build/build.ps1 /t:Publish`, Release/win-x64 NativeAOT: exit 0, 0 warnings, 0 errors. - Eight checks against the published native executables passed: help, version, and no-argument behavior for both CLIs, LightSwitch JSON help, and PowerDisplay JSON argument errors. PowerDisplay's existing missing-command exit code remains 1. - `git diff --check` passed. Restores used the configured host NuGet source. --------- Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
9 of 11 tasks
Boliang Zhang (LegendaryBlair)
pushed a commit
that referenced
this pull request
Oct 16, 2026
## Summary of the Pull Request Add `LightSwitch_CLICommand` and `PowerDisplay_CLICommand` using the Settings CLI telemetry pattern, providing a basic usage signal for the two CLIs. Each invocation records an allowlisted `CommandName` and a `Successful` flag based on its final exit code, through the existing diagnostics consent check. Related CLI work: #50459 and #48632. Telemetry pattern: #50507. ## PR Checklist - [x] **Tests:** Existing CLI regression suites pass. - [x] **Localization:** No new user-facing strings. - [x] **Dev docs:** Not applicable to this telemetry-only change. - [x] **New binaries:** No new binaries or external dependencies; ManagedTelemetry was already a transitive dependency. ## Detailed Description of the Pull Request / Additional comments - Wrap execution in `src/modules/LightSwitch/LightSwitch.Cli/Program.cs` and `src/modules/powerdisplay/PowerDisplay.Cli/Program.cs` to attempt one event per invocation, including help/version, validation failures, and exceptions. Telemetry failures preserve the command's output, exit code, and exception. - Match Settings CLI's first-token allowlist. Option-first and response-file invocations use `unknown`; raw arguments, monitor IDs, profile values, and file paths are excluded from telemetry. - Enable `EventSourceSupport` in both NativeAOT projects and preserve the event properties for trimming. ## Validation Steps Performed - Repository `build-essentials.ps1`, Debug/x64: exit 0. - Existing CLI regression tests passed with `vstest.console.exe`: LightSwitch **221/221**, PowerDisplay **130/130**. - Publish both CLIs with `tools/build/build.ps1 /t:Publish`, Release/win-x64 NativeAOT: exit 0, 0 warnings, 0 errors. - Eight checks against the published native executables passed: help, version, and no-argument behavior for both CLIs, LightSwitch JSON help, and PowerDisplay JSON argument errors. PowerDisplay's existing missing-command exit code remains 1. - `git diff --check` passed. Restores used the configured host NuGet source. --------- Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com> (cherry picked from commit 7f149ab) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
11 tasks
Yu Leng (moooyo)
added a commit
that referenced
this pull request
Oct 20, 2026
) ## Summary of the Pull Request Generating a bug report while PowerToys is running fails with `Failed to copy PowerToys folder` because the Runner holds `settings.json.cli-lock` exclusively. Exclude that root synchronization file before copying settings so report generation can proceed. This fixes the regression introduced by #50507. ## PR Checklist - [ ] Closes: No linked issue. - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: Not applicable. Validation is manual; no automated test additions are included in this PR. There are no new user-facing strings, development documentation, binaries, packaging changes, or external documentation changes. ## Detailed Description of the Pull Request / Additional comments In `tools/BugReportTool/BugReportTool/Main.cpp`, create the report directory and copy each settings-root entry recursively, skipping `settings.json.cli-lock` with a case-insensitive filename comparison. The file is excluded before any copy attempts to open it. Other diagnostic files and nested directories are preserved, and unrelated copy errors retain the existing failure path. ## Validation Steps Performed - Built `BugReportTool` in Release x64 using the repository build wrapper: exit code 0 for commit `27489cd9746830a3a196074bf47409b47a2f6242`. - On local Windows, ran the installed `0.102.2883.0` report tool and then the PR executable against real PowerToys user data while the same installed Runner held the root CLI lock exclusively throughout. Each child used separate temporary and output directories; installed binaries were untouched. The baseline exited naturally with code 1, `Failed to copy PowerToys folder`, and no ZIP. - The PR executable exited naturally with code 0 and generated a 919,234-byte ZIP containing 641 entries. Verified parseable settings JSON, 43 nonempty nested Runner logs, nonempty GPO/Windows/monitor reports, and exclusion of the root `settings.json.cli-lock`. The full run took about 97 minutes because registry collection was slow on this host. - CI run 391437 passed all 10 checks. Release x64 and ARM64 builds completed with 0 errors and 0 warnings. The existing x64 native suite reported 11,066 passed, 21 skipped, and 0 failed; ARM64 tests were skipped. --------- Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
Boliang Zhang (LegendaryBlair)
pushed a commit
that referenced
this pull request
Oct 21, 2026
) ## Summary of the Pull Request Generating a bug report while PowerToys is running fails with `Failed to copy PowerToys folder` because the Runner holds `settings.json.cli-lock` exclusively. Exclude that root synchronization file before copying settings so report generation can proceed. This fixes the regression introduced by #50507. ## PR Checklist - [ ] Closes: No linked issue. - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: Not applicable. Validation is manual; no automated test additions are included in this PR. There are no new user-facing strings, development documentation, binaries, packaging changes, or external documentation changes. ## Detailed Description of the Pull Request / Additional comments In `tools/BugReportTool/BugReportTool/Main.cpp`, create the report directory and copy each settings-root entry recursively, skipping `settings.json.cli-lock` with a case-insensitive filename comparison. The file is excluded before any copy attempts to open it. Other diagnostic files and nested directories are preserved, and unrelated copy errors retain the existing failure path. ## Validation Steps Performed - Built `BugReportTool` in Release x64 using the repository build wrapper: exit code 0 for commit `27489cd9746830a3a196074bf47409b47a2f6242`. - On local Windows, ran the installed `0.102.2883.0` report tool and then the PR executable against real PowerToys user data while the same installed Runner held the root CLI lock exclusively throughout. Each child used separate temporary and output directories; installed binaries were untouched. The baseline exited naturally with code 1, `Failed to copy PowerToys folder`, and no ZIP. - The PR executable exited naturally with code 0 and generated a 919,234-byte ZIP containing 641 entries. Verified parseable settings JSON, 43 nonempty nested Runner logs, nonempty GPO/Windows/monitor reports, and exclusion of the root `settings.json.cli-lock`. The full run took about 97 minutes because registry collection was slow on this host. - CI run 391437 passed all 10 checks. Release x64 and ARM64 builds completed with 0 errors and 0 warnings. The existing x64 native suite reported 11,066 passed, 21 skipped, and 0 failed; ARM64 tests were skipped. --------- (cherry picked from commit 3d6827a) Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Boliang Zhang (LegendaryBlair)
added a commit
that referenced
this pull request
Oct 27, 2026
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Add Workspaces **list** and synchronous **launch** through a thin native CLI and shared GUI/CLI execution core. Related to #49900; capture/create/CRUD are excluded. Usage and contracts: `doc\devdocs\modules\workspaces-cli.md`. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [ ] Closes: N/A - partial scope of #49900. <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [x] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [x] **Tests:** Added/updated and all pass (scoped local runs below; CI/release gates remain) - [x] **Localization:** All end-user-facing strings can be localized - [x] **Dev docs:** Added/updated - [x] **New binaries:** Added on the required places - [x] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [x] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - current integration: `installer\PowerToysSetupVNext\CliShims.wxs` - [x] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - existing discovery; session-peer companion signing updated - [x] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - N/A: existing signing pipeline - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: N/A - follow-up not filed. <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments ### Shared execution, conditional process boundary ```mermaid flowchart TB EDITOR["Editor process<br/>C# / WPF"] -->|"start GUI Launcher"| ADAPTER SHELL["Terminal / script"] -->|"CLI shim starts CLI"| ADAPTER subgraph CALLER["Caller process: CLI.exe OR Launcher.exe in GUI mode"] ADAPTER["Thin entry adapter"] START["WorkspacesSession::Start<br/>snapshot + context check"] LOCAL["WorkspacesSession::Execute()<br/>function inside the caller process"] ADAPTER -->|"in-process"| START START -->|"verified Medium: in-process"| LOCAL LOCAL -.->|"typed return via Start"| ADAPTER end subgraph HOST["Elevated callers only: Medium host process<br/>PowerToys.WorkspacesLauncher.exe"] HANDOFF["Host entry<br/>receive and validate SessionHandoff"] REMOTE["WorkspacesSession::Execute()<br/>function inside this host process"] HANDOFF -->|"function call within the same process"| REMOTE end START -->|"elevated: create host<br/>read-only snapshot + restricted handles"| HANDOFF REMOTE -.->|"private anonymous result pipe"| START START -.->|"host outcome returned"| ADAPTER LOCAL <-->|"named pipes"| ARRANGER["WindowArranger process"] REMOTE <-->|"named pipes"| ARRANGER LOCAL <-->|"named pipes"| UI["Existing WPF Launcher UI process"] REMOTE <-->|"named pipes"| UI classDef shared fill:#dbeafe,stroke:#2563eb,color:#172554 class START,LOCAL,REMOTE shared ``` The caller box represents **one of the two entry executables**, not both in one process. Blue nodes are code statically linked from `WorkspacesLib.lib`, not a DLL or shared service. **Medium GUI/CLI callers execute in their own process without another Launcher host.** Only elevated callers create a verified Medium host through the existing `run_non_elevated` helper; it calls the same `WorkspacesLib\LaunchExecution.cpp` core. No elevated fallback. **`Execute()` is a function, not another EXE.** The host entry and its `Execute()` share the same process ID. Execution uses a worker thread inside that process, not another Launcher process. The two `Execute()` nodes represent the same library implementation running in alternative caller/host contexts. - **Shared behavior:** one preparation, launch, arrangement, confirmation and history flow. GUI retains progress; CLI shows only required existing confirmation UI. GUI Cancel and console cancellation use the shared stop/result path; already-started apps survive. Arranger callbacks are stopped and joined before their helper owner is released. An unresponsive inline Shell call yields `outcomeUnknown` before the one-shot adapter exits, rather than killing a thread or claiming cancellation succeeded. - **Contracts:** `list` is read-only; summary JSON reuses existing names. All arranged = `completed`/0; partial progress = `partial`/10; no progress = `failed`/10. Incomplete, fractional or invalid final states yield `outcomeUnknown`/9. Persistence verification failure retains exit 11 and displays application results in both text and JSON modes. The existing `LaunchedAndMoved` enum and numeric IPC values are unchanged. - **Persistence/integration:** preserve IDs, initialize missing legacy IDs, update history best-effort; unsaved GUI drafts do not write saved configuration/history. Only shim `bin` goes on PATH. Editor sibling-tool resolution is executable-relative. - **Telemetry:** one frontend `Workspaces_CLICommand` event when optional diagnostics are enabled, following #50507's fixed command category + success model. No workspace names/IDs, paths, arguments or error text; the Medium host does not double-count. Uses the existing native telemetry channel; documented in `DATA_AND_PRIVACY.md`. - **Release IPC:** exact session-owner PID and official CLI/Launcher identities remain checked. CI companion signing now includes CLI, Launcher, arranger and Launcher UI; production signature checks are not disabled. - **Console isolation:** console workspace targets get their own console; inline execution does not detach, redirect or share the CLI's console. - **Launch and Edit:** a missing temporary draft now falls back to the saved workspace before GUID validation; malformed existing drafts still fail. The existing UI regression explicitly checks that no draft is present. - **GUI file errors:** unreadable saved files and drafts show the existing localized file-reading dialog with the correct source filename; malformed-file dialogs also retain that context. Public CLI error JSON is unchanged. - **UI-test transport:** shared value setters place target options before `--` and pass selectors/values literally. This fixes the leading-dash command-line inputs rejected by CI's winapp 0.7.1 without changing Workspaces test payloads or assertions. ### Changed-file breakdown Full PR versus main, not just the latest commit. Each file is counted once; test projects and fixtures are grouped under tests. These are file categories, not process or library boundaries. | Category | Files | |---|---:| | CLI adapter, output, resources and project | 7 | | Shared session/execution entry, contracts, IPC, storage and telemetry | 19 | | Launcher engine/host adapter, arranger and UI | 18 | | Managed storage and Editor path compatibility | 4 | | Common helpers | 9 | | Tests and fixtures | 24 | | Build, installer and signing | 6 | | Documentation and privacy catalog | 4 | | **Total** | **91** | The Launcher engine sources are compiled into `WorkspacesLib` even though their source files remain under `WorkspacesLauncher`; the table does not imply a separate engine process. **Scope/known follow-ups:** general Editor save/conflict redesign and the pre-existing localized-name/package-version matching bug are deferred. Final GUI progress presentation still needs follow-up; this update does not claim to fix its spinner-before-close behavior. The native C++ parser is retained by the PR author's decision; a managed System.CommandLine migration is not included. This does not amend the repository-wide CLI convention. <details> <summary>List output and shared confirmation UI</summary>   </details> <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed x64 Debug builds of the affected product and UI-test/fixture projects passed; Release core, ModuleInterface, arranger, Launcher and CLI builds also passed. The pre-GUI-error scoped native run passed **160 tests**. Two deterministic paused-dispatch regressions reproduced `0xC0000005` before the teardown fix (snapshot and final-result callbacks); both now return acknowledged cancellation. Test hooks are compiled only into the fixture, not production builds. **48 signing-selection** tests passed earlier against unchanged selection logic. The preceding missing-draft fix passed **39 focused tests** plus the complete local-host `winapp` Launch and Edit flow, with settings/pointer/Editor state restored. This is targeted host validation, not full local OS-matrix sign-off. The GUI error follow-up `8ea5619586` passed **33 focused native tests in each of Debug and Release**, including a regression that failed before the fix. Both real saved-file/draft error dialogs were driven locally with UIA; original configuration bytes and draft absence were restored. The CI transport follow-up `e0945376e6` passed **19 focused shared-harness tests in each of Debug and Release**. Using the hash-verified winapp **0.7.1** archive from the failing CI revision, the original invocation reproduced `invalid_arguments`; the fixed wrappers passed **nine owned-UI setter checks** for leading options, quoted text, empty text, and negative numeric values. The TextBox, editable ComboBox, NumberBox, and Slider setters share the corrected argument boundary. This is focused wrapper validation, not a claim that the full Workspaces suite ran locally. <details> <summary>Commands and results</summary> Used the verified side-by-side SDK 10.0.303; no global/repository SDK or package-source change. With `$root='D:\PowerToys-workspace-cli'`, from each affected project directory: ```powershell & "$root\tools\build\build.ps1" -Platform x64 -Configuration Debug -ExtraArgs @("/p:SolutionDir=$root\", '/p:BuildProjectReferences=false', '/p:WorkspacesCliLiveTests=true') # Passed, exit 0. & "$root\tools\build\build.ps1" -Platform x64 -Configuration Release -ExtraArgs @("/p:SolutionDir=$root\", '/p:BuildProjectReferences=false') # Passed, exit 0, for core/arranger/Launcher/CLI. ``` Missing Release UI dependencies were first built with project references enabled: ```powershell # From src\modules\Workspaces\WorkspacesLauncherUI: & "$root\tools\build\build.ps1" -Platform x64 -Configuration Release -ExtraArgs @("/p:SolutionDir=$root\") # Passed, exit 0. ``` Pre-GUI-error scoped native run (`$evidence` is the local report directory): ```powershell $env:WORKSPACES_CLI_LIVE_TESTS='1' & 'C:\Program Files\Microsoft Visual Studio\18\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' "$root\x64\Debug\tests\Workspaces\Workspaces.Lib.UnitTests.dll" '/TestCaseFilter:FullyQualifiedName~CliContractTests|FullyQualifiedName~CliJsonOutputTests|FullyQualifiedName~CliRuntimeTests|FullyQualifiedName~CliHandoffTests|FullyQualifiedName~CliWorkerTests|FullyQualifiedName~WorkspaceStoreTests|FullyQualifiedName~SignatureVerificationTests|FullyQualifiedName~SignatureTrustTests|FullyQualifiedName~ExecutableTargetTests|FullyQualifiedName~ElevatedLaunchGateTests|FullyQualifiedName~PendingLaunchApprovalTests' "/ResultsDirectory:$evidence" '/Logger:trx;LogFileName=teardown-race-green.trx' '/Logger:console;verbosity=minimal' # Passed: 160; failed/skipped: 0; exit 0. & 'C:\Program Files\Microsoft Visual Studio\18\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' "$root\x64\Debug\tests\Workspaces\Workspaces.Lib.UnitTests.dll" '/TestCaseFilter:FullyQualifiedName~CliContractTests|FullyQualifiedName~JsonUtilsTests' "/ResultsDirectory:$evidence" '/Logger:trx;LogFileName=missing-draft-headless.trx' '/Logger:console;verbosity=minimal' # Passed after the draft fix: 39; failed/skipped: 0; exit 0. Invoke-Pester -Script 'D:\PowerToys-workspace-cli\.pipelines\tests\uiTestSigningSelection.Tests.ps1' -PassThru # Passed: 48; failed: 0. git diff --check # Passed, exit 0. ``` Telemetry lifecycle tests use a recording sink and synthetic commands; they neither transmit telemetry nor change diagnostic consent. Recorded host UI actions (3892 was this run's owned Editor PID, not a reusable PID): ```powershell winapp ui 'invoke' 'EditButton' '-a' '3892' '--json' winapp ui 'invoke' 'LaunchEditButton' '-a' '3892' '--json' winapp ui 'invoke' 'SnapshotButton' '-a' '3892' '--json' winapp ui 'invoke' 'SaveButton' '-a' '3892' '--json' # All passed, exit 0; fixture startup, exact placement, recapture and persisted IDs were asserted. ``` </details> Latest shared-harness build/test commands, from `src\common\UITestAutomation.Next.UnitTests`: ```powershell & "$root\tools\build\build.ps1" -Platform x64 -Configuration Debug -ExtraArgs @("/p:SolutionDir=$root\") & "$root\tools\build\build.ps1" -Platform x64 -Configuration Release -ExtraArgs @("/p:SolutionDir=$root\") # Both passed, exit 0, including analyzers. & "$root\x64\Debug\tests\UITestAutomation.Next.UnitTests\net10.0-windows10.0.26100.0\UITestAutomation.Next.UnitTests.exe" --filter 'FullyQualifiedName~WinappCliTests|FullyQualifiedName~SessionTests' --report-trx --report-trx-filename ci-set-value-unit.trx --results-directory $evidence & "$root\x64\Release\tests\UITestAutomation.Next.UnitTests\net10.0-windows10.0.26100.0\UITestAutomation.Next.UnitTests.exe" --filter 'FullyQualifiedName~WinappCliTests|FullyQualifiedName~SessionTests' --report-trx --report-trx-filename ci-set-value-unit-release.trx --results-directory $evidence # Each passed: 19; failed/skipped: 0; exit 0. ``` **CI status:** [391837](https://dev.azure.com/shine-oss/62769a65-d989-45e3-803c-9ad21fcf2ea2/_build/results?buildId=391837) **succeeded** on current head `e0945376e6`, tested as merge `e27f537028` with main `79ceeee01c`. SDK/x64/ARM64 builds passed, and **34/34 Workspaces UI tests passed on each of Windows 10 x64, Windows 11 x64, and Windows 11 ARM64**, with zero failures or skips. Finished 2026-10-26 16:18:46 UTC. The preceding [391820](https://dev.azure.com/shine-oss/62769a65-d989-45e3-803c-9ad21fcf2ea2/_build/results?buildId=391820) on `8ea5619586` passed product builds but had 29/34 UI tests pass on each platform. All five failures were leading-dash textbox values rejected by winapp 0.7.1; the shared helper was identical to main and predates this PR. The setter fix resolves those failures without changing Workspaces product code or weakening assertions. Fresh High-parent/UAC, installer servicing and broader mixed-DPI validation remain release gates. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 664ee900-ce2d-4112-ac57-395314d818dc
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.
Related to #4649
Summary
Adds an initial command-line interface for managing PowerToys module enabled state.
The CLI supports:
listto show each PowerToys module's effective enabled state, including Group Policy overrides.status <module>to show one module's effective enabled state.enable <module>to persist a module as enabled.disable <module>to persist a module as disabled.list --jsonandstatus <module> --jsonfor machine-readable module-state output.This PR intentionally does not expose in-module settings such as hotkeys or module-specific options. Those settings should belong to each module's own CLI surface when needed. This keeps the Settings CLI scoped to cross-module Settings ownership: module enablement.
Changes are Group Policy aware: policy-locked module states are reflected in
list/statusand rejected byenable/disable. Mutations use an exclusive lock shared with Runner to prevent Runner shutdown from overwriting a CLI update, so PowerToys must be exited beforeenableordisable; read-onlylistandstatusremain available while it is running. Command failures return a non-zero process exit code. The CLI is included in the solution, signing manifest, and standard PATH-visible CLI shim infrastructure.The CLI emits one usage telemetry event per invocation when optional PowerToys diagnostics are enabled. It records only a fixed command category (
list,status,enable,disable, help/version, or unknown) and success status; module names, settings values, and other arguments are never included.This first version also intentionally does not include backup/restore/reset. Those operations need a separate design using the existing
.ptbbackup contract and a constrained reset model.Issue 4649 asks for a command-line way to access the Settings applet. This PR is related to that request, but deliberately focuses on module enablement and does not launch the Settings UI.
Main implementation approach
PowerToys.Settings.Cli.exeis a thin standalone client that directly references the existing Settings UI Library in-process. It reuses the library's General Settings repository and persistence code forGeneralSettings.Enabled.<Module>rather than starting a module pipeline or introducing a new Runner IPC endpoint.The CLI is integrated with the repository's standard PATH-visible CLI mechanism. The installed
PowerToys.Settings.CLI.exeshim resolves to the self-containedPowerToys.Settings.Cli.exeunderWinUI3Apps, and the shim/installer mapping is kept in sync through the existing manifest checks.End-to-end experience
The following is representative output from the built executable. Exit PowerToys before using
enable/disable, then start it again to apply the saved module state.CLI convention compliance
System.CommandLineand the repository'sParservalidation path.--kebab-caseoptions and documented help text.0for success and1for command/runtime errors.ManagedCommon.Loggerand reports failures to stderr while retaining log details.PowerToysTelemetryevent pattern with aProductAndServiceUsageprivacy tag and documents the event inDATA_AND_PRIVACY.md.tools/CliShim/CliShimManifest.propsandinstaller/PowerToysSetupVNext/CliShims.wxs..pipelines/ESRPSigning_core.json.Common.SelfContained.props.Validation
CliShim.UnitTestsbuilt successfully; all 8 shim tests passed, including the manifest-to-installer mapping check.list --json, targeted status, reversible enable/disable, and non-zero errors for an unknown module and the removedtogglecommand. The original module state was restored after testing.Notes for review
The current implementation persists module enabled-state changes through the existing Settings UI Library command-line settings path. It does not add a new authenticated Runner IPC endpoint. To avoid races with Runner's settings persistence,
enableanddisablerequire PowerToys to be exited; start PowerToys afterward to apply the saved state.