.net 6 - Dotnet build failed on Razor files with code behind

Hi Community,

My build failed when I enable SonarQube analysis on my project : I have a lot of errors on my code behind for Razor files.
Sample of error:

RankTableComponent.razor.cs(10,48): error CS0103: The name ‘Color’ does not exist in the current context

It seems the same issue than this topic: SonarScanner does not support .NET 6 Razor Compiler / Source Generators

  • The workaround works but it isn’t good solution for me.

Versions used:

  • SonarQube: 9.9
  • SonarScanner for MSBuild 5.14
  • MSBuild version 17.6.8+c70978d4d for .NET


I don’t believe CS0103 is coming from us. Our rule S103 is about line length. Also, we don’t raise issues at error level in the build. In fact, we have a warning in the docs about allowing other Roslyn analyzers to do that.

And finally, we’ve been adding Razor support in recent versions. That announcement I linked to is for functionality that should be available in the upcoming SonarQube 10.3.