Razor compiler warnings are not shown in dotnet build output
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
Razor compiler warnings (e.g., deprecation warnings) are not shown in the `dotnet build` output, even though they are triggered by Razor component usage.
This makes it easy to miss important warnings such as usage of obsolete APIs in `.razor` files.
### Expected Behavior
The warning should appear in the `dotnet build` output, just like C# warnings from `.cs` files.
### Actual behavior
The warning is not shown in the `dotnet build` output.
### Steps To Reproduce
Use the following Razor component:
```
Page not found
```
This produces the following compiler warning:
CS0618: Property 'Microsoft.AspNetCore.Components.Routing.Router.NotFound()' is obsolete: 'NotFound is deprecated. Use NotFoundPage instead.'
### Exceptions (if any)
_No response_
### .NET Version
10.0.200
### Anything else?
- The issue appears to affect Razor-generated code in general, not just this specific example.
- It seems that warnings emitted during Razor compilation or source generation are not consistently surfaced in the standard build output.
- This can lead to missed deprecations and other important diagnostics.
### Environment
**.NET SDK:**
Version: 10.0.200
Commit: 40cd698e5c
Workload version: 10.0.200-manifests.b7278506
MSBuild version: 18.3.0-release-26119-122+40cd698e5
### Impact
Developers may unknowingly ship code that relies on obsolete or problematic APIs because these warnings are either omitted from the build output or disregarded due to the `` annotation in the generated `.g.cs` files.
### Sample
Consider the App.razor file in the following attachement
[razorwarnings.zip](https://github.com/user-attachments/files/26304256/razorwarnings.zip)
Contributor guide
Assessment
This issue has not been assessed yet.