Show SonarLint Issues from Visual Studio correctly in the build output

  • Operating system: Windows 10
  • IDE name : Visual Studio 2022 (17.0.2)
  • SonarLint plugin Sonar C# analyzer version: 8.38.0.467
  • Connected to SonarQube Version 8.9.5 (build 50698) Developer Edition

Hi everyone,

I have a scenario which I cannot wrap my head around.
We ware using Visual Studio 2022 with SonarLint Sonar C# analyzer v8.38.0.467

Usually when building our projects within our Azure Pipeline and publishing the quality gate information to the server, it works fine.
But now we have a Visual Studio project with SonarLint and the issue seems to be the following:

There are some Sonar Warnings which are shown in the IDE, but when I run “dotnet build -p:Configuration=Release”, the “Sonar Warnings” (starting with S) don’t seem to be shown
in the build output, only the other warnings. I would expect, that all issues are shown in the output.
Sonar Exclusion path cannot be the problem (We are using exclusions within the pipeline, but triple checked that the path of the files are not excluded).

Therefore when publishing the quality gate information, of course, there are no issues reported (since the output does not contain the issues seen in Visual Studio).

In this image you see some of the warnings (these are some S1172 and some CS1998 warnings). All together there are 7 CS1998 and 18 S1172…

…, but in the output only the 7 CS1998 are shown.

(Sorry for the german language in the screenshots :grin:)

But of course the S*- Warnings should also be in the output to be correctly reported to the SonarQube project.

How can I approach this problem ?
Is there something wrong with the .ruleset file since it contains the Issues from the Sonar Server project linked in the Visual Studio project ?

bild3

Or are we building the project incorrectly ? Or anything else ?

If you need any more information to help me, please let me know, I am not sure, what informations you should be provided in this case…

Thanks in advance

Cheers
Claudius

Hi @chauser,

SonarLint only shows issues in the IDE. It does not push issues to SonarQube/SonarCloud.

If you want to run analysis in on your CI pipelines and push the issues to the server then you need to use one of the batch mode scanners. Since you are using Azure DevOps, you can use the SonarQube extension for Azure DevOps. See the docs for more information.

Hi @duncanp,

Thank you for your answer.
We do have a full Azure DevOps integration and use it frequently with other solutions in our codebase.
With other solutions the scanner and the analysis publisher works fine, that is not the problem here.

What I am wondering is the fact that the solution in which this problem occurs, is set up the same way as the other solutions. I don’t seem to find the point where I can tackle this issue.
In the other solutions this phenomenon (that the Sonar Issue are not part of the build output) does not occur.
My question was, how can I tackle this issue, since I don’t seemto find the difference to other solutions when it comes to e.g. configuration.

Any help is appreciated :slight_smile:

Cheers

Can you share a screenshot of your build pipeline, and the logs for the prepare analysis, msbuild and run analysis steps please?

Hello @duncanp
Here are the logs of the requested steps
dotnet build.txt (22.4 KB)
prepare analysis.txt (2.0 KB)
run code analysis.txt (48.7 KB)

Maybe you can see something, that I don’t see :slight_smile:

Cheers

It’s possible you seeing by this bug i.e. false positives for S1172 in the IDE, which would explain why those issues are shown in the IDE but not when analysing in the CI pipeline.

That bug was fixed in the v8.38 of the Sonar C# analyzer.
That version of the Sonar C# analyzer was embedded in SonarLint for Visual Studio v6.2.

Which version of SonarLint are you using?

Where can I see which SonarLint I am using ? (Sorry for the stupid question)
EDIT: Found it, nevermind. I am using Version 6.4.1.47693

But I think you’re hint is correct. When I am using this SonarLint Version (6.4) with the v8.37 of the Sonar C# analyzer, the issues appear, but when I combine it with the version v8.38 respectively not using the analyzer at all, the issues are not shown.

So I think you are right. The updated version seems to be solution.
I double checked it with a colleague and it worked with her installation as well.

Thanks for the support

Cheers

1 Like

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