I want the build to fail when there's a warning. I have the following at .csproj
<PropertyGroup>
<MSBuildTreatWarningsAsErrors>true</MSBuildTreatWarningsAsErrors>
</PropertyGroup>
When I try to build from Build menu or Ctrl + B, the build output shows an error but it succeeds:
If I build from command line with dotnet build, it fails as expected.
Environment: Visual Studio 2022 Professional, .NET 6.0



