diff --git a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.props b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.props
index 20ad68340d7d..90da8c160887 100644
--- a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.props
+++ b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.props
@@ -36,18 +36,6 @@ Copyright (c) .NET Foundation. All rights reserved.
false
-
-
- true
- true
- true
- true
diff --git a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets
index d00c93c78f80..8364e1349107 100644
--- a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets
+++ b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets
@@ -23,6 +23,22 @@ Copyright (c) .NET Foundation. All rights reserved.
false
+
+
+ true
+ true
+ true
+ true
diff --git a/test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/VanillaWasmTests.cs b/test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/VanillaWasmTests.cs
index c4678820fc3a..80c20a72e23a 100644
--- a/test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/VanillaWasmTests.cs
+++ b/test/Microsoft.NET.Sdk.BlazorWebAssembly.Tests/VanillaWasmTests.cs
@@ -43,11 +43,26 @@ public void Build_Works()
[TestMethod]
[CoreMSBuildOnly]
- [DataRow(null, "true", "true")]
- [DataRow("false", "false", "false")]
- public void Build_ResolvesBlazorDiagnosticsFeatureSwitches(string diagnosticsEnabled, string expectedDiagnosticsEnabled, string expectedFeatureValue)
+ [DataRow(null, false, "true", "true")]
+ [DataRow("false", false, "false", "false")]
+ // Setting the property from the project body must take effect (dotnet/sdk#55489): the defaults are
+ // evaluated at Sdk.targets time so a value set in the .csproj is honored, not just a global property.
+ [DataRow("false", true, "false", "false")]
+ [DataRow("true", true, "true", "true")]
+ public void Build_ResolvesBlazorDiagnosticsFeatureSwitches(string diagnosticsEnabled, bool setInProjectFile, string expectedDiagnosticsEnabled, string expectedFeatureValue)
{
var testInstance = CreateAspNetSdkTestAsset("BlazorWasmMinimal");
+
+ if (setInProjectFile && diagnosticsEnabled is not null)
+ {
+ testInstance.WithProjectChanges((project, doc) =>
+ {
+ var propertyGroup = new XElement("PropertyGroup");
+ propertyGroup.Add(new XElement("BlazorWebAssemblyDiagnosticsEnabled", diagnosticsEnabled));
+ doc.Root.Add(propertyGroup);
+ });
+ }
+
var build = CreateBuildCommand(testInstance);
var arguments = new List
@@ -58,7 +73,7 @@ public void Build_ResolvesBlazorDiagnosticsFeatureSwitches(string diagnosticsEna
"-getProperty:HttpActivityPropagationSupport"
};
- if (diagnosticsEnabled is not null)
+ if (!setInProjectFile && diagnosticsEnabled is not null)
{
arguments.Add($"/p:BlazorWebAssemblyDiagnosticsEnabled={diagnosticsEnabled}");
}