Skip to content

dotnet watch (Aspire server): launching a web project fails with "The given key '1021' was not present in the dictionary" when browser tools are disabled #57358

Todo

Description

@karolz-ms

Describe the bug

With Microsoft.DotNet.HotReload.Watch.Aspire 11.0.100 (dotnet/dotnet 297acf930fb0f5c07fd4e51d78e521b4ad2e5d1f), every launch of a web project whose Hot Reload browser tools are off fails:

aspire watch server ❌ Failed to start '/src/Api/Api.csproj': The given key '1021' was not present in the dictionary.

Browser tools are off when BrowserToolsBuildOutputs.FromProjectSettings returns null, for example:

  • a non-Debug configuration without EnableHotReloadInRuntimeConfigDevFile=true;
  • StaticWebAssetsEnabled or JSModulesEnabled set to false.

Cause

BrowserToolsBuildOutputsExtensions.FromProject logs LogEvents.BrowserToolsNotSupportedByProjectSettings. HotReloadClient's LogEvents allocates IDs from 1000, so this warning is EventId 1021.

The watcher's LoggerFactory.Logger.Log (IReporter.cs#L107) calls MessageDescriptor.GetDescriptor(eventId) for every non-zero EventId. That method indexes s_descriptors directly. BrowserToolsNotSupportedByProjectSettings is not mirrored into a MessageDescriptor, so logging the warning throws KeyNotFoundException. ProcessLauncherFactory.HandleRequestAsync reports that exception as the launch failure.

The same code is on release/11.0.1xx and on main: as of 7a6b95d, SharedSecretBuildOutputsExtensions.cs#L31 logs the event and IReporter.cs#L170-L171 still indexes the dictionary directly. Microsoft.DotNet.HotReload.Watch.Aspire 10.0.4xx doesn't have the browser tools path and isn't affected.

Repro

  1. Create a Microsoft.NET.Sdk.Web project (net10.0) and select SDK 11.0.100.
  2. Run it under the Aspire watch server with Configuration=Release and Optimize=false in the server's environment. That's how Aspire builds watched services in Release, without the workaround below.
  3. The resource launch fails with the message above.

Plain dotnet watch probably fails the same way, because it uses the same logger. I haven't verified that.

Suggested fix

Do either or both of the following:

  • mirror LogEvents.BrowserToolsNotSupportedByProjectSettings (and any other LogEvents entries that aren't mirrored yet) into MessageDescriptor;
  • make GetDescriptor tolerant: s_descriptors.GetValueOrDefault(id), falling back to level-based emoji selection.

Workaround

The build host can set EnableHotReloadInRuntimeConfigDevFile=true for non-Debug builds, which the SDK documents as the switch for its hot reload build outputs. Projects that disable static web assets or JS modules have no workaround other than not watching them.

Activity

  1. added
    untriaged
    on Nov 25, 2026
  2. locked and limited conversation to collaborators on Nov 25, 2026
  3. unlocked this conversation on Nov 25, 2026
  4. added
    Area-Watch
    cookie
    and removed
    untriaged
    on Nov 25, 2026
  5. github-actions commented on Nov 25, 2026

    @github-actions
    Contributor

    🎯 Agentic Issue Triage

    Triage Assessment:

    • 🏷️ Labels: Area-Watch dotnet-watch Bug cookie Issue Monster Loves Cookies!
    • 💻 Assignment: @maraf | @dotnet/hot-reload @dotnet/aspnet-blazor-eng
    • 🟩 Confidence: high - The issue names dotnet watch code under src/Dotnet.Watch, matching the Area-Watch CODEOWNERS section.

    Similar issues: #57123 (duplicate)

    ➡️ Summary: Logging the BrowserToolsNotSupportedByProjectSettings event (1021) throws KeyNotFoundException in MessageDescriptor.GetDescriptor, failing launches when browser tools are disabled. Fix by mirroring the event or making GetDescriptor tolerant of unknown IDs.

    Generated by 🏷️ Issue Triage for #57358 · copilot · auto (Claude Sonnet 5.5) · ~17 AIC · ⌖ ~2 AIC · ⊞ 15.5K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-WatchBugcookie

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions