Your project contains C# files which cannot be analyzed with the scanner you are using

I am running sonarqube:latest in a Docker container locally on my development machine to get some stuff working.

I’m trying to analyze a C# project that runs on .NET Core 3.1. Looking at this page I assumed I could use the .NET Core Global Tool to scan it but that gives me the following error while running the end step:

WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html

This also happens when I try to use .NET 5 dotnet <path to SonarScanner.MSBuild.dll> etc. It does nicely scan all the TypeScript and CSS stuff that’s in my project but in the end there are no C# results in SonarQube.

Any idea what I’m doing wrong?

Hi,

Welcome to the community!

Can you provide your exact analysis and build commands?

 
Ann

I’m using the .NET global tool dotnet-sonarscanner to run the analysis:

dotnet sonarscanner begin /k:"project-key"  /d:sonar.login="myAuthenticationToken" /d:"sonar.host.url"=http://localhost:9000
dotnet build 
dotnet sonarscanner end /d:sonar.login="myAuthenticationToken"

I’ve also asked this question on Stack Overflow where I already have some more info: c# - Failing SonarQube analysis on .NET Core 3.1 project - Stack Overflow.

Apparently having this setting in a Directory.Build.Targets file makes the analysis fail for at least some projects:

<Target Name="ChangeAliasesOfReactiveExtensions" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
  <ItemGroup>
    <ReferencePath Condition="'%(FileName)' == 'System.Interactive.Async'">
      <Aliases>ix</Aliases>
    </ReferencePath>
  </ItemGroup>
</Target>

Removing this (and fixing the resulting build errors) still gives me the same warning when running it on the whole solution. So I know need to debug which project is giving problems and why that’s resulting in this warning.

Any pointers on how to do that or what could be the problem?

Hi,

I’m already officially over my head here, & I’ve flagged this post internally for specialist help.

 
Ann

2 Likes