Fix BlazorWebAssemblyDiagnosticsEnabled so it can be set from a .csproj - #55537
Merged
javiercn merged 2 commits intoJul 31, 2026
Conversation
|
Azure Pipelines: 3 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot
AI
changed the title
[WIP] Fix BlazorWebAssemblyDiagnosticsEnabled setting in .csproj
Fix BlazorWebAssemblyDiagnosticsEnabled so it can be set from a .csproj
Jul 30, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Blazor WebAssembly SDK’s MSBuild evaluation order so BlazorWebAssemblyDiagnosticsEnabled (and the derived feature-switch defaults) can be set from within a project file body, not only via global properties.
Changes:
- Moves
BlazorWebAssemblyDiagnosticsEnabledand the defaulting logic forMetricsSupport,EventSourceSupport, andHttpActivityPropagationSupportfromMicrosoft.NET.Sdk.BlazorWebAssembly.Current.propstoMicrosoft.NET.Sdk.BlazorWebAssembly.Current.targets. - Extends
Build_ResolvesBlazorDiagnosticsFeatureSwitchesto validate behavior whenBlazorWebAssemblyDiagnosticsEnabledis set inside the.csproj(not just via/p:).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/VanillaWasmTests.cs | Expands the regression test matrix to cover setting BlazorWebAssemblyDiagnosticsEnabled in the project file body. |
| src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets | Adds targets-time defaults for BlazorWebAssemblyDiagnosticsEnabled and the three derived feature properties so .csproj values are honored. |
| src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.props | Removes the earlier props-time defaults that prevented .csproj body overrides from taking effect. |
oroztocil
approved these changes
Jul 31, 2026
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.
BlazorWebAssemblyDiagnosticsEnabledand the diagnostics feature switches it drives (MetricsSupport,EventSourceSupport,HttpActivityPropagationSupport) were defaulted inMicrosoft.NET.Sdk.BlazorWebAssembly.Current.props. MSBuild importsSdk.propsbefore the project body, so a value set in a.csprojwas read too late — the documented opt-out only worked as a global property (/p:) or fromDirectory.Build.props.Changes
Current.propstoCurrent.targets— into the firstPropertyGroup, which evaluates atSdk.targetstime (after the project body is read) and before the imported SDK targets initialize the switches tofalse. The property logic is otherwise unchanged, so the default (all switchestrue) and the existing/p:opt-out behave as before.Build_ResolvesBlazorDiagnosticsFeatureSwitcheswith cases that set the property in the project body (for bothtrueandfalse), covering the.csprojpath the previous/p:-only test missed.Notes
6_0/5_0.targetsand the MonoWasmFeatures.propsthat default these switches tofalsewhen unset.HttpActivityPropagationSupport→System.Net.Http.EnableActivityPropagationmapping lives in the base .NET SDK targets and is unaffected; no extraRuntimeHostConfigurationOptionis needed.