Sonar scanner for MSBuild to analyse .net code not working

Hi,

SonarQube on-prem version 7.9 (sonarqube is running in as a docker container)
SonarQube Scanner for Jenkins plugin version 2.13.1

I am trying to do the sonarqube analysis for a .Net Core 3.1 project through a jenkins pipeline. I am building the code on jekins server (Windows server 2012 R2) and then uploading analysis on sonar server using opencover.

When .Net Core 2.x SDK is installed on my jenkins server the analysis works fine with SonarScanner for MSBuild 5.2.2 - .NET Core 2.0.

image

But as 2.X core version is going to be EOL(out of support) soon, we have uninstalled it and now we have .Net core version 3.1 and above installed on the jenkins server and we have selected SonarScanner for MSBuild 5.2.2 - .NET Core 3.0 from the global tool configuration.
But now the sonarqube analysis fails and we get the below error:

###########################################################################
E:\workspace\test-dotnet31-59>dotnet “E:\Program Files (x86)\Jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\SonarQube_for_MSBuild_Core\SonarScanner.MSBuild.dll” begin /k:“Test_dotnetcore31_iis” /n:“Test_dotnetcore31_iis” /v:“1.0” /d:sonar.cs.opencover.reportsPaths=“E:\workspace\test-dotnet31-59\opencover.xml” /d:sonar.host.url=http://sonarqube.org-name.com:9002
SonarScanner for MSBuild 5.2.2
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories

09:34:22.525 Updating build integration targets

09:34:22.872 Failed to request and parse ‘http://sonarqube.org-name:9002/api/server/version’: Object reference not set to an instance of an object.
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass18_0.<b__0>d.MoveNext()
— End of stack trace from previous location where exception was thrown —
at SonarScanner.MSBuild.PreProcessor.SonarWebService.DoLogExceptions[T](Func`1 op, String url)
at SonarScanner.MSBuild.PreProcessor.SonarWebService.DownloadServerVersion()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.GetServerVersion()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.WarnIfSonarQubeVersionIsDeprecated()
at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs localSettings)
at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.Execute(String args)
at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
at SonarScanner.MSBuild.BootstrapperClass.Execute()
at SonarScanner.MSBuild.Program.Execute(String args, ILogger logger)
at SonarScanner.MSBuild.Program.Execute(String args)
at SonarScanner.MSBuild.Program.Main(String args)
at SonarScanner.MSBuild.Program.(String args)

###########################################################################

We are able to access ‘http://sonarqube.org-name:9002/api/server/version’ as well.
The Sonarqube version we are using is 7.9.6.41879

So for running Sonar Scanner for Jenkins is it mandatory to have .Net Core 2.X installed on the jenkins server?
We are analysing the Net Core 3.1 project. (SonarScanner for MSBuild 5.2.2 - .NET Core 3.0 and .Net Core 2.x is not installed on jenkins server, only 3.1 core sdk and .Net 5.0 sdk)
Same error occurs for .Net 5.0 project. (SonarScanner for MSBuild 5.2.2 - .NET 5.0 and .Net Core 2.x is not installed on jenkins server, only 3.1 core sdk and .Net 5.0 sdk)

Hi,

Is it mandatory to have .Net Core 2.x (SDK or Runtime) to be installed on the machine where we run the sonarscanner for MSBuild, for scanning .net core 2.x, .net core3.x and .net 5.0 projects ?

@ganncamp @mickaelcaro can you please help me here? am i missing something?

Hi @tushar

Since version 5.3.1 of the Scanner for .NET (and 4.22 version of the extension), the minimum required version to run the Scanner is .NET Core 3 (is you are building under linux), for windows this is .NET Framework 4.6+

HTH,
Mickaël

1 Like

Thank you @mickaelcaro for clearing the doubt.

A post was split to a new topic: Which versions of .net framework are supported by the Scanner for .NET

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