Skip to content

Fix winapp new -t reactor when another template pack also registers reactor - #949

Merged
Nikola Metulev (nmetulev) merged 2 commits into
mainfrom
azchohfi-fix-reactor-template-ambiguous-short-nam
Sep 30, 2026
Merged

Nikola Metulev (nmetulev) merged 2 commits into
mainfrom
azchohfi-fix-reactor-template-ambiguous-short-nam

Conversation

@azchohfi

@azchohfi Alexandre Zollinger Chohfi (azchohfi) commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

If you install the standalone Microsoft.UI.Reactor.Templates pack alongside the WinUI templates pack, both packs register the short name reactor. winapp new -t reactor passed that name straight to dotnet new. Because the name matches templates in two packs, dotnet new refused it and scaffolding failed.

winapp new now checks which short names other installed packs also register. It creates the WinUI pack's template using the first of its aliases that no other pack claims:

  • One name is shared: winapp new -t reactor scaffolds the WinUI pack's Reactor Blank App by running dotnet new reactor-blank. The template name winapp shows and reports in --json ("Template": "reactor") is unchanged.
  • Every name is shared: winapp new stops before asking for a project name. It exits with code 4 and prints a message that names the conflicting pack and how to remove it.

winapp new still only installs, lists and scaffolds templates from the official WinUI pack.

Usage Example

This is the output observed with both packs installed (WinUI pack 0.0.7-alpha, .NET SDK 10.0.401):

> dotnet new list reactor
Template Name                              Short Name                             Language  Tags
-----------------------------------------  -------------------------------------  --------  ------------------------------------------
Microsoft.UI.Reactor App                   reactor                                [C#]      Windows/WinUI/Desktop/Reactor
Reactor Blank App (Experimental)           reactor,reactor-blank,winui-reactor    [C#]      Windows/WinUI/Desktop/Reactor/Experimental
...

Before (main): winapp new -t reactor --name BeforeFix --use-defaults exits with code 5.

❌ Failed to scaffold WinUI app: Unable to resolve the template, the following installed templates are conflicting:
Identity                                         Template Name       Short Name                           ...  Package
Microsoft.UI.Reactor.StandIn.CSharp              Microsoft.UI.Re...  reactor                              ...  Microsoft.UI.Reactor.Templates
Microsoft.WindowsAppSDK.Reactor.CSharp.BlankApp  Reactor Blank A...  reactor,reactor-blank,winui-reactor  ...  Microsoft.WindowsAppSDK.WinUI.CSharp.Templates

After (this PR): winapp new -t reactor --name AfterFix2 --use-defaults exits with code 0. With --verbose, the log shows dotnet new reactor-blank, and the scaffolded app builds with 0 errors.

✅ Created WinUI app AfterFix2 at ...\AfterFix2.
⚠  reactor is an experimental template. It depends on prerelease packages whose
APIs can change or be removed in a future release.
👉 Next: cd "AfterFix2" then winapp run.

When another pack claims every alias (reactor, reactor-blank and winui-reactor), winapp new exits with code 4 and creates nothing:

❌ Template 'reactor' can't be created because every short name it has (reactor, reactor-blank, winui-reactor) is also registered by another installed template pack (Microsoft.UI.Reactor.Templates), so 'dotnet new' can't tell them apart. Remove the other pack with 'dotnet new uninstall Microsoft.UI.Reactor.Templates', then re-run 'winapp new'.

With only the WinUI pack installed, winapp new -t reactor still runs dotnet new reactor, as before.

Related Issue

Fixes #948

Type of Change

  • 🐛 Bug fix

Checklist

  • New tests added for new functionality (if applicable)
  • Tested locally on Windows
  • docs/usage.md updated (if CLI commands changed)

Screenshots / Demo

N/A (CLI behavior; see the observed output above).

Additional Notes

  • Where the pack list comes from: winapp new already runs dotnet new uninstall to confirm which templates the WinUI pack owns. That output lists every installed pack and its aliases, so this fix needs no extra dotnet call.
  • How the conflicting pack was reproduced: Microsoft.UI.Reactor.Templates isn't published on nuget.org. The template project that microsoft/microsoft-ui-reactor removed in Use the Windows App SDK dotnet new templates and remove our own microsoft-ui-reactor#1277 used the short name reactorapp, not reactor. The repro therefore used a local pack built to match the issue exactly: package ID Microsoft.UI.Reactor.Templates, name "Microsoft.UI.Reactor App", short name reactor, and tags Windows/WinUI/Desktop/Reactor. It ran in an isolated DOTNET_CLI_HOME.
  • Limitation: templates built into the .NET SDK don't appear in dotnet new uninstall output, so a collision with one of them isn't detected. None of them use WinUI or Reactor short names.
  • Validation: all WinUiTemplateCatalogTests and NewCommand* tests pass (181 passed, 1 skipped), including new handler tests for both cases above. scripts\build-cli.ps1 -SkipTests -SkipMsix -SkipNpm succeeds, and the CLI schema is unchanged.

…t name

dotnet new refuses a short name that matches templates from more than one
installed pack, so installing Microsoft.UI.Reactor.Templates alongside the
WinUI pack broke 'winapp new -t reactor'. Parse every pack's aliases from
the existing 'dotnet new uninstall' output and scaffold with the first alias
no other pack registers (e.g. reactor-blank). When every alias is shared,
fail early naming the conflicting pack and how to remove it.

Fixes #948

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8e69318a-5a91-45e5-a82c-9c7b91487c8b
Copilot AI balanced review requested due to automatic review settings September 30, 2026 17:42

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.

Copilot review overview

🟢 Approval recommended

The implementation is focused and covered by 95 passing targeted tests, a successful solution build, and NativeAOT publish.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes ambiguous Reactor template aliases by selecting a unique alias or failing with actionable guidance.

Changes:

  • Detects aliases registered by other template packs.
  • Scaffolds using the first unique alias.
  • Adds tests and user documentation.
File Description
WinUiTemplateCatalog.cs Parses installed packs and identifies shared aliases.
NewCommand.cs Uses unique aliases and reports complete conflicts.
WinUiTemplateCatalogTests.cs Tests pack parsing and alias selection.
NewCommandHandlerTests.cs Tests successful fallback and conflict failure.
docs/​usage.md Documents collision handling and recovery.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@azchohfi Alexandre Zollinger Chohfi (azchohfi) added the agent-preparing Agent is addressing feedback or completing required validation and CI label Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Build Metrics Report

Validation passed. All required build and validation jobs succeeded.

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 57.29 MB 57.31 MB 📈 +12.5 KB (+0.02%)
CLI (x64) 57.34 MB 57.35 MB 📈 +13.5 KB (+0.02%)
MSIX (ARM64) 23.79 MB 23.79 MB 📉 -2.4 KB (-0.01%)
MSIX (x64) 25.26 MB 25.27 MB 📈 +9.8 KB (+0.04%)
NPM Package 49.63 MB 49.65 MB 📈 +12.5 KB (+0.02%)
NuGet Package 49.74 MB 49.75 MB 📈 +8.9 KB (+0.02%)

.NET Test Results (TRX reports)

Other suites are reflected in the overall validation status above.

✅ 7886 passed, 37 skipped out of 7923 tests in 1118.0s (+7 tests, -141.5s vs. baseline)

Test Coverage

✅ 86.3% line coverage, 80.9% branch coverage · ✅ no change vs. baseline

CLI Startup Time

64ms median (x64, winapp --version) · ⚠️ +15ms vs. baseline

Try This Build

Installs the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing.

& ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 949
Switching between builds often?

Put the tool on your PATH once:

& ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPath

Then this build is just:

winapp-pr 949

Run winapp-pr with no arguments to pick from a list of open PRs.


Updated 2026-09-30 21:42:51 UTC · commit bbcc652 · workflow run

@azchohfi Alexandre Zollinger Chohfi (azchohfi) added ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Sep 30, 2026

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.

Copilot review overview

🟢 Approval recommended

The implementation matches the reported behavior, and the build plus 95 targeted tests passed.

Review effort: Balanced
Findings: None

@azchohfi Alexandre Zollinger Chohfi (azchohfi) added agent-preparing Agent is addressing feedback or completing required validation and CI and removed ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge labels Sep 30, 2026
@azchohfi Alexandre Zollinger Chohfi (azchohfi) added ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Sep 30, 2026
@nmetulev
Nikola Metulev (nmetulev) merged commit 89c69dc into main Sep 30, 2026
46 checks passed
@nmetulev
Nikola Metulev (nmetulev) deleted the azchohfi-fix-reactor-template-ambiguous-short-nam branch September 30, 2026 22:01
@azchohfi Alexandre Zollinger Chohfi (azchohfi) removed the ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge label Oct 1, 2026
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.

winapp new -t reactor fails when Microsoft.UI.Reactor.Templates is also installed (ambiguous short name)

3 participants