Scanner for MSBuild via Jenkins not analyzing .cs files

Hi, I’ve setup our project and Sonar Scanner for MSBUILD via Jenkins plugin. The build passes in the end and I get a successful artifact but no .cs files get analyzed, only .cshtml and .aspx.

versions used

  • SonarQube 8.2
  • SonarScanner for MSBuild - .NET Fwk 4.6
  • MSBuild 14.0.25420.1
  • Project targets .NET 4.6.1
  • Build node Windows Server 2016

error observed

I constantly get the following error in every project that I try to build:

CSC : warning AD0001: Analyzer 'SonarAnalyzer.Rules.CSharp.XmlExternalEntityShouldNotBeParsed' threw an exception of type 'System.IO.FileNotFoundException' with message 'Could not load file or assembly 'System.ValueTuple, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.'.

steps to reproduce

Run the build from Jenkins.
Probably happens because using the older MSBuild.

potential workaround

I haven’t found any workarounds, but have tried older versions of SonarScanner down to 3.0 and still the same behavior.

Any help would be appreciated!

The issue now seems to be solved by Installing .NET Framework Runtime 4.7.2.

Now I have another issue where it says that File does not exist in the analysis context.
I’m getting the following error now it seems it still does not submit analysis support for the .CS files.

WARN: File 'E:\workspace\migrationtool\BusinessLayer\LogWebApplication\App_Start\BundleConfig.cs' referenced by the protobuf 'MetricsInfo' does not exist in the analysis context

I’ve found out the issue with the last problem as well and want to share it here if others get a similar problem.

Jenkins agent was installing itself in C:\jenkins. Project were saved in E:\workspace.
Now inside the C:\jenkins folder there is a workspace folder which is a link to the E:\workspace. This works correctly for builds but confuses the Scanner since all source .cs files get the path from the C: drive.

This is solved by changing that jekins build node directory is E: now workspace is available directly without going trough any symlinks.

It seems that there is an issue with SonarScanner in this scenario when using symlinks in Windows.

thanks @nikola.vitanovic ! we opened an issue to track this problem