Analysis report missing on simple c# project

Hi, I am new to Sonar and failed to configure it with my project in C#.
I am running Sonar 7.2 on my local machine ( also tried on sonarcloud)

when i run these 3 commands

SonarScanner.MSBuild.exe begin /k:“Survey”
MSBuild.exe /t:Rebuild /v:diag
SonarScanner.MSBuild.exe end

i get some warnings on command 2 and 3 which looks like this

CSC : warning CS8032: An instance of analyzer SonarAnalyzer.Rules.CSharp.ThreadStaticWithInitializer cannot be created from C:\Users\RizwanBashir\AppData\Local\Temp.sonarqube\resources\0\SonarAnalyzer.CSharp.dll : Could not load file or assembly ‘System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified… [C:\work\SurverySoft\SurveySoftMain\SurveySoftMain.csproj]
CSC : warning CS8032: An instance of analyzer SonarAnalyzer.Rules.CSharp.MutableFieldsShouldNotBePublicReadonly cannot be created from C:\Users\RizwanBashir\AppData\Local\Temp.sonarqube\resources\0\SonarAnalyzer.CSharp.dll : Could not load file or assembly ‘System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified… [C:\work\SurverySoft\SurveySoftMain\SurveySoftMain.csproj]
CSC : warning CS8032: An instance of analyzer SonarAnalyzer.Rules.CSharp.GetHashCodeEqualsOverride cannot be created from C:\Users\RizwanBashir\AppData\Local\Temp.sonarqube\resources\0\SonarAnalyzer.CSharp.dll : Could not load file or assembly ‘System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified… [C:\work\SurverySoft\SurveySoftMain\SurveySoftMain.csproj]

and for command 3
15:53:45.436 WARN: SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project.
15:53:46.853 WARN: Analyzer working directory does not exist: ‘C:\work\SurverySoft.sonarqube\out\0\output-cs’. Analyzer results won’t be loaded from this directory.
15:53:46.947 WARN: Analyzer working directory does not exist: ‘C:\work\SurverySoft.sonarqube\out\1\output-cs’. Analyzer results won’t be loaded from this directory.

any help would be highly appreciated.

Warning CS8032 occurs if the version of the Roslyn used by the C# compiler is older than the version used by the SonarC# analyzer. The latest version of the SonarC# analyzer requires Roslyn v1.3 or later.

The C# compiler is bundled with the MSBuild tools, so check the version of MSBuild you are using.

If you are building using the version of MSBuild bundled with Visual Studio then you need to be using Visual Studio 2015 Update 3 or later.

If you are building using a standalone version of MSBuild then you need MSBuild 15 (downloadable from https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017).

Fixing that warning might also fix the last one (“Analyzer working directory does not exist”).

1 Like