Skip to content

Warn when MetadataUpdaterSupport is false in dotnet watch - #54264

Merged
jonathanpeppers merged 1 commit into
release/10.0.4xxfrom
jonathanpeppers/dotnet-watch-metadata-updater-warning
May 14, 2026
Merged

jonathanpeppers merged 1 commit into
release/10.0.4xxfrom
jonathanpeppers/dotnet-watch-metadata-updater-warning

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented May 12, 2026 •

Copy link
Copy Markdown
Member

Warn when project configuration disables Hot Reload in dotnet watch, matching the checks that VS uses in dotnet-project-system PR 738329.

Background

Previously, dotnet watch only checked StartupHookSupport (and PublishAot/PublishTrimmed which imply it). It did not warn when the runtime's MetadataUpdater.IsSupported would be false, leading to confusing behavior — e.g. running dotnet watch in a non-Debug configuration would silently fail to apply Hot Reload updates.

Changes

TFM >= .NET 11 — check MetadataUpdaterSupport. This property is now correctly set by the runtime starting in .NET 11.

TFM < .NET 11 — check Optimize == false and DebugSymbols == true, since MetadataUpdaterSupport was not reliably set for older frameworks. This matches what VS does.

Files changed

  • Versions.cs — Added Version11_0 constant
  • BuildNames.cs — Added MetadataUpdaterSupport, Optimize, DebugSymbols constants
  • HotReloadAppModel.cs — Added TFM-gated checks with link to runtime PR
  • SourceFileUpdateTests.HotReloadNotSupported.cs — Replaced MetadataUpdaterSupport=False test case with Optimize=True (test TFM is net10.0, so the < 11 path is exercised)

Copilot AI review requested due to automatic review settings May 12, 2026 14:14
@jonathanpeppers
jonathanpeppers requested review from a team and tmat as code owners May 12, 2026 14:14
@jonathanpeppers
jonathanpeppers changed the base branch from main to release/10.0.4xx May 12, 2026 14:15
@jonathanpeppers
jonathanpeppers requested review from a team as code owners May 12, 2026 14:15

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 wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@jonathanpeppers
jonathanpeppers force-pushed the jonathanpeppers/dotnet-watch-metadata-updater-warning branch 2 times, most recently from 46550c8 to e990aac Compare May 12, 2026 14:17
@tmat

tmat commented May 12, 2026

Copy link
Copy Markdown
Member

Note that when PublishTrimmed is true the value of MetadataUpdaterSupport used to be false even in debug build. This was fixed by dotnet/runtime#127163

@tmat tmat left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the fix dotnet/runtime#127163 only targets .NET 11 runtime. Instead of checking MetadataUpdaterSupport we might need to check Optimize and DebugType properties like VS does.

@jonathanpeppers

Copy link
Copy Markdown
Member Author

Could a project set <MetadataUpdaterSupport>false</MetadataUpdaterSupport> as well?

What made me look at this, is this issue:

It made me wonder if hot reload works for a $(Configuration) named something like DebugProd or Prod.

@tmat

tmat commented May 12, 2026 •

Copy link
Copy Markdown
Member

Yes, MetadataUpdaterSupport can be set by project.

I think what we need to do is:
If TFV >= 11 then check MetadataUpdaterSupport, otherwise check DebugSymbols == true && Optimize == false.

VS currently does the latter. I'll change it to check the same condition as watch.

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (2)

src/Dotnet.Watch/Watch/AppModels/HotReloadAppModel.cs:110

  • GetBooleanPropertyValue(PropertyNames.DebugSymbols) is invoked without an explicit defaultValue, so it falls back to false (see ProjectGraphUtilities.cs:87-88). If the DebugSymbols property is not evaluated/set on the ProjectInstance for any reason, this will incorrectly emit the "project does not support Hot Reload" warning and abort. Consider passing an explicit defaultValue consistent with MSBuild defaults (and document the assumption), as is done a few lines above for MetadataUpdaterSupport and StartupHookSupport.
            if (!project.ProjectInstance.GetBooleanPropertyValue(PropertyNames.DebugSymbols))
            {
                logger.Log(MessageDescriptor.ProjectDoesNotSupportHotReload_Property, PropertyNames.DebugSymbols, "False", PropertyNames.DebugSymbols, "True");
                return false;
            }

test/dotnet-watch.Tests/HotReload/SourceFileUpdateTests.HotReloadNotSupported.cs:15

  • The test method name ChangeFileInAotProject and the parameter name propertyName made sense when the inputs were AOT/trimming-related. Now that the theory also covers Optimize=True (and ideally MetadataUpdaterSupport=False/DebugSymbols=False), the method name is misleading. Consider renaming to something like ChangeFileInProjectThatDoesNotSupportHotReload.
    public async Task ChangeFileInAotProject(string propertyName, string propertyValue)

Add the same hot reload support check for MetadataUpdaterSupport that
already exists for StartupHookSupport. When MetadataUpdaterSupport is
false (e.g. Release configuration), dotnet watch now warns that the
project does not support Hot Reload and suggests setting the property
to True.

Also adds a test case for MetadataUpdaterSupport=False alongside the
existing StartupHookSupport test.

Co-authored-by: Copilot <[email protected]>
@jonathanpeppers
jonathanpeppers force-pushed the jonathanpeppers/dotnet-watch-metadata-updater-warning branch from 5d781ca to 3b9b343 Compare May 14, 2026 13:48
@jonathanpeppers

Copy link
Copy Markdown
Member Author

Merging, the failure looks unrelated:

Confirmed — completely unrelated to this PR. The failure is:

Test: Microsoft.NET.Sdk.BlazorWebAssembly.Tests.dll.1 (a Helix work item)
Error: "The Helix Work Item failed" — it's a BlazorWebAssembly test in the FullFramework: windows (x64) leg
Details: The work item exited with code 1, likely due to a test crash or infra issue. The "Failed" strings in the logs are just MSBuild messages about "Failed to load prune package data from PrunePackageData folder" — not actual test assertion failures.
Nothing related to dotnet-watch, MetadataUpdaterSupport, Optimize, DebugSymbols, or any files touched by this PR.

Build Analysis check is also green.

@jonathanpeppers
jonathanpeppers merged commit 3827773 into release/10.0.4xx May 14, 2026
28 of 30 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers/dotnet-watch-metadata-updater-warning branch May 14, 2026 18:03
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Watch dotnet-watch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants