Is it Possible to use external analyzers like Roslyn analyzer from Azur DevOps Builds instead of Visual Studio?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

we are using SonarQube 7.9.3 LTS and want to use external analyzer like Roslyn analyzer from Azure DevOps Builds. Is it possible to do so?

we are already using these external analyzers from Visual Studio extensions but unable to do it from Azure DevOps Builds.

Do we have any plugins available for the Roslyn Analyzers for SonarQube 7.9.3 LTS ?

Hi,

FYI, I’ve combined your topics since they seem to be the same.

Regarding your actual question I need to start with the reminder that 7.9.* is no longer the LTS. SonarQube 8.9 was released last week, and it’s the new/current LTS. (Sorry to be pedantic. :smiley:)

To add Roslyn rules to your analysis, simply let them run as part of you’re build; they’ll be picked up automatically. You can get more details at the bottom of this docs page:

Issues from third-party Roslyn analyzers (including Roslyn analyzers provided by Microsoft) are included in the MSBuild output and imported by default into SonarQube so no properties exist to enable that behavior…

 
HTH,
Ann

We referenced StyleCop analyzers in all the projects that need the rules to implement and then ran SonarQube analysis from Visual Studio. Then SonarQube automatically imported those issues when it scans those projects. But when we try from Azure DevOps build pipeline (SonarQube analysis is one of the task), StyleCop issues are not imported when it scans the projects.

Hi,

Thanks for the further detail. I’m now officially out of my depth, so I’ve tagged this thread to draw the attention of the experts.

 
Ann

Thanks Ann for taking a look at this issue. Can you please let us know if you have any update on this from the experts?

hello @shasi - external analyzer reports should be picked up automatically by the scanner for .NET / Azure Devops Extension

You need to reference these analyzers in your CSPROJ / VBPROJ files (or a common Directory.build.props used by all projects) and they will be picked up by MSBuild and executed during the build. Our scanner reads out of the box the build analysis output and uploads them to SQ/SC.

We are using StyleCop.Analyzers in our CI (with SonarCloud integration - it works the same for SonarQube) and results are correctly imported to SonarCloud. Check: