Hi Chris,
To analyze your .NET Core applications on Linux you need the following installed:
-
SonarQube 6.7+ Note that the latest version of SonarC# is not compatible with older versions of SonarQube and you will have to upgrade your instance.
-
Scanner for MSBuild 4.0+ (from this thread)
-
SonarC# 6.7+ Note that the plugin is still not available on the SonarQube Update Center and you will have to
install it manually-
.NET Core SDK 2.0 I doubt you could install earlier version anymore, but if you already have one, you will need to upgrade.
-
Mono -
JRE once you install it, you will have to set your JAVA_HOME variable, for example, on my machine the value is:
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/
A very important prerequisite is to make a couple of "bat" files in the Scanner for MSBuild folder executable. I extracted my Scanner for MSBuild at "~/Tools/Scanner" and the command to make the files executable is:
chmod u+x ~/Tools/Scanner/sonar-scanner-3.0.3.778/bin/*
Then to analyze your .NET Core application:
mono ~/Tools/Scanner/SonarQube.Scanner.MSBuild.exe begin /d:sonar.login=XXXXXXXXXXXXXXXXXXXXXXX /k:ConsoleApplication1 /d:sonar.host.url=
http://localhost:9000dotnet restore
dotnet msbuild /t:rebuild
mono ~/Tools/Scanner/SonarQube.Scanner.MSBuild.exe end /d:sonar.login=XXXXXXXXXXXXXXXXXXXXXXX
It is very important to use "dotnet msbuild /t:rebuild" instead of any other combination, because the current targets have a problem when building multiple target frameworks simultaneously with "dotnet build" (e.g. no "msbuild" and no /t:rebuild). For VSTS the workaround is to put /t:rebuild in the additional arguments on the Build Task in your build definition.
Another thing is that the .NET Core projects need to either have <ProjectGuid> property or to be added to a solution. ProjectGuid is not added if you create your projects with the dotnet command and the Guid is required by SonarQube. If you created your projects with Visual Studio you probably already have this property.
One last thing: if you are importing coverage data, you will most probably have to add <DebugType>Full</DebugType> in each of your projects. More information about this problem can be found here:
https://github.com/Microsoft/vstest/issues/800
I hope this helps,
Valeri Hristov