You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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
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
Create a Microsoft.NET.Sdk.Web project (net10.0) and select SDK 11.0.100.
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.
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.
➡️ 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 · ◷
Activity
Ship .NET 10 and .NET 11 watchers and fix watch build SDK selection
github-actions commentedon Nov 25, 2026
🎯 Agentic Issue Triage
Triage Assessment:
@maraf| @dotnet/hot-reload @dotnet/aspnet-blazor-enghigh- 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.