SonarScanner does not support .NET 6 Razor Compiler / Source Generators

Hi,

in .NET 6 the Razor Compiler was updated to be implemented using Source Generators.
Now our Azure DevOps Server build pipeline fails if we enable SonarScanner. A workaround is to disable Source Generators in .csproj.

<PropertyGroup>
  <UseRazorSourceGenerator>false</UseRazorSourceGenerator>
</PropertyGroup>

Versions:
SonarScanner for Azure DevOps v5.1.1 (SonarScanner for MSBuild 5.4)
SonarQube v9.2

Related issue:
C# Sonar Scanner with Source Generators - Report a bug - SonarSource Community

Related pages:
Using Source Generators with Blazor components in .NET 6 (andrewlock.net)
ASP.NET Core updates in .NET 6 Preview 2 - .NET Blog (microsoft.com)

Hi @dhaas. Thanks for reporting the issue and for the workaround.

I’ve created a S4.NET bug: #1125

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Hello @dhaas

Could you please describe what do you mean by the pipeline fails? Do you have some exception or some tasks failing or it finishes successfully and you don’t have metrics or issues imported for the project?

All the best,
Čaba