0

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".

TylerH
  • 20,799
  • 66
  • 75
  • 101
user3231247
  • 123
  • 1
  • 7

2 Answers2

2

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
Nicolas B.
  • 7,245
  • 17
  • 29
  • Fantastic! thank you. I was looking for info on whether the new scanner for msbuild supported .net core but somehow i didn't find the site you linked for. thanks :) – user3231247 May 02 '17 at 13:03
  • @XtianGIS: Microsoft itself seems to be deprecating _xproj_ format , see Q&A linked in my answer. – Nicolas B. Nov 08 '17 at 14:58
  • @NicolasB.-SonarSourceTeam you are right, but they were deprecated in version 2.0, I currently have projects in netcore 1.1, and they are in .xproj format – XtianGIS Nov 08 '17 at 15:50
  • In case you solution contains net standard projects, you need v4.x version of SonarQube.Scanner.MSBuild.exe at least. – Yan Oreshchenkov Jan 17 '18 at 12:07
0

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
TylerH
  • 20,799
  • 66
  • 75
  • 101
Mahendra
  • 447
  • 6
  • 7