3

I have a SonarQube 5.3.1 in place with the C# Plugin 4.5.0 installed. Basic included rules are detected as expected.

Now, I want to use the Roslyn SDK project (https://github.com/SonarSource-VisualStudio/sonarqube-roslyn-sdk) to add my tailor made analyzers into account.

I'm pretty sure they are okay because they are raised in both Visual Studio and when using msbuild in command line.

My problem now is to be able to upload those issues into Sonar, I must be missing something.

I obviously use the SonarQube Scanner for MSBuild v2.0, have installed my generated jar and have activated the rules (the appear in "Code Smell"), try to build a project with which my rules should break (and they do, as I said earlier), but it does not seem to pick up my rules.

The doc (https://blogs.msdn.microsoft.com/visualstudioalm/2016/02/18/sonarqube-scanner-for-msbuild-v2-0-released-support-for-third-party-roslyn-analyzers/) says it should "produce an error report containing analysis errors and warnings for all of the analyzers" and then upload it to SonarQube, but I cannot find this report. At the very least, just a SonarLint output file with no related rule whatsoever.

I've also tried with the Wintellect Analyzer as the github page suggests (https://github.com/SonarSource-VisualStudio/sonarqube-roslyn-sdk) with no success.

My guess is there's something wrong somewhere in the configuration but I don't know where, any idea ?

  • What version of msbuild are you using? For third party analyzers msbuild14 is required. – Tamas Nov 26 '16 at 20:55
  • Also, could you update your C# plugin on the SQ server? That also contains an updated SonarQube Scanner for MsBuild. When you do the "begin" step, the analyzers are downloaded from the SQ server. I'm not sure if this directly shows up in the log or not. But during the "msbuild" step, you can check which analyzer DLLs are being passed to the CSC CoreCompile build target. Can you verify that all the analyzer DLLs are added there? Finally, can you verify that the analysis results JSON file contains the expected issues? – Tamas Nov 26 '16 at 20:56
  • I'm actually using MsBuild 14 and I clearly can see my analyzer appearing in the log. The JSON file does not contain much... The last C# Plugin version requires to update the SQ server to 5.6, I'm gonna try it... – Franck Desbrosses Dec 14 '16 at 10:21
  • A few heads up after a while. We eventually did succeed with a 6.2 SQ server and Visual Studio 2015 installed on the build agent... – Franck Desbrosses Apr 10 '17 at 19:03

1 Answers1

0

For each custom analyzer you want to use in SonarQube (example: Wintellect), you need to use the Roslyn SDK for SonarQube tool to create plug-ins that can be imported into SonarQube. Directions and info can be found here.

Tom Atwood
  • 468
  • 3
  • 17