Analyze project with Java, C++ and C# in Azure DevOps

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube Developer 8.2 with Java-, C++, C# scanners

  • what are you trying to achieve
    Analyze our product with contains

    • Java 8 (buid with ant)
    • C++ and C++/CLI wrapper (build with Visual Studio 2019)
    • C# (build with Visual Studio 2019, including libraries and WIX installer)

    Java is using C++ with JNI.
    All is build in Azure DevOps Server with an yaml pipeline.

  • what have you tried so far to achieve this
    To start I tried to set up the Java analysis without code coverage:

    - task: sonarsource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@4
      displayName: 'Prepare analysis on SonarQube'
      continueOnError: true
        SonarQube: Sonarqube
        projectKey: ProductName.Java
        projectName: ProductName.Java
        projectVersion: '$(Build.BuildNumber)'
        extraProperties: |

    - task: BatchScript@1
      displayName: 'Build Tool Studio Java Archive'
        filename: 'Build_release.cmd' # This script sets some environment variables and calls several times ant
        modifyEnvironment: true
    - task: sonarsource.sonarqube.6D01813A-9589-4B15-8491-8164AEB38055.SonarQubeAnalyze@4
          displayName: 'Complete the SonarQube analysis'
          condition: succeededOrFailed()

Unfortunately, the Analyze task fails.

Do I have any chance to analyze all three parts in one project in SonarQube?
What is the recommended way to analyze multi-language projects?

ok, I got the Java part analyzed when switching parameter in Prepare task:

  # Prepare SonarQube analysis
  - task: sonarsource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@4
    displayName: 'Prepare analysis on SonarQube'
      SonarQube: Sonarqube
      scannerMode: CLI
      extraProperties: |
        sonar.projectDescription=Product Description
        sonar.links.scm=our url

The above questions with multi-language analyes remain open.

Hi, you’ll need a SQ project for each technology stack.

If the C++ and C# files are all referenced inside the MSBuild projects, they can be analyzed with the Scanner for MSBuild (see Solution with a Mix of C# and C++) and can be the same project in SQ.

Thanks @Andrei_Epure.

As with the above prepare task the libraries where not recogniced, I modified it. Now I get errors regarding the path, see InvalidPathException for I split it, as it has nothing to do with multi-language projects.

Thanks, I hope Azure DevOps ALM integration can handle multiple anaylzes in one PR. I’ll see.

The Visual Studio solution contains C++, C++/CLI and C#, so the mixed approch I’ll follow.

You can see how we do it for our mixed C# / Java project, using Azure Pipelines and SonarCloud - search for “SonarCloud” in

1 Like

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