user3231247
user3231247

Reputation: 123

SonarQube with .NET Core 1.1

After my team migrated completely to .NET Core 1.0 using SonarQube was sort of out of the picture, but then I read Running SonarQube against an ASP.Net Core solution/project where it is stated that, with Core 1.1, migrating from project.json to .csproj it might be possible to use MSBUILD to build the project(s) and run SonarQube analysis on the code.

Has anyone been able to pull this off? After we upgraded one of our solutions to Core 1.1 I've been trying to get SonarQube to analyse this code.

If tried both using msbuild /t:rebuild and different variations on dotnet msbuild

to build the project during the Sonar analysis but neither has produced anything other than SonarQube responding with the standard "make sure the build succeeded and that all SonarQube commands where run from the same folder" error.

This in spite of the fact that msbuild /t:rebuild does return a "build succeeded".

Upvotes: 0

Views: 2080

Answers (2)

Mahendra
Mahendra

Reputation: 457

I was looking for the same answer however it is same as for the previous versions.

I have these three steps for doing the same. dotnet msbuild comes when you install the .net core frameworkdotnet core cli.

The main difference is instead of "MsBuild" we have to use "dotnet msbuild".

SonarQube.Scanner.MSBuild.exe begin /k:"org.sonarqube:sonarqube-scanner-msbuild" /n:"<yourprojectname>" /v:"<version>"

*dotnet msbuild* "<Path to your .net core project>\ConsoleAppForSonar.sln"

SonarQube.Scanner.MSBuild.exe end

Upvotes: 0

Nicolas B.
Nicolas B.

Reputation: 7331

Two aspects here:

  • on the Microsoft side: I believe .csproj is now the de-facto format (see this Q&A). Old formats (.xproj,project.json) should be migrated to csproj using VS2017 toolset.
  • on the SonarQube side: .Net Core projects are supported starting from Scanner for MSBuild v2.3

Upvotes: 2

Related Questions