Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (7k points)

I have Sonar server on my AKS with Sonar docker image (image: sonarqube:7.1).

I have my CI/CD pipeline for .net application and using SonarScanner ( sonar) .

When I am running my pipeline I am getting this error:

Description : Run scanner and upload the results to the SonarQube server.

Version : 4.11.0

Author : sonarsource

Help : Version: 4.11.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

/usr/bin/dotnet /home/vsts/work/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/4.11.0/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll end

SonarScanner for MSBuild 4.10

Using the .NET Core version of the Scanner for MSBuild

Post-processing started.

##[error]The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.

Possible causes: 

The project has not been built - the project must be built in between the begin and end steps

An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.

The begin, build and end steps have not all been launched from the same folder

None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)

The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.

My pipeline:

- task: SonarQubePrepare@4

  inputs:

    SonarQube: 'SonarQube-Dev'

    scannerMode: 'MSBuild'

    projectKey: 'Test'

    projectName: 'Test'

    extraProperties: |

      # Additional properties that will be passed to the scanner,

      # Put one key=value per line, example:

      # sonar.exclusions=**/*.bin

      sonar.projectBaseDir=/src

      sonar.sources=src 

- task: MSBuild@1

  inputs:

    solution: '/*.sln'

    restoreNugetPackages: true

    clean: true  

1 Answer

0 votes
by (31.9k points)

You can use .NetCLIBuild instead of MSBuild .

The pipeline should be as below

- task: DotNetCoreCLI@2

      inputs:

        command: 'restore'

        projects: '**/*.csproj'

        workingDirectory: '/src'

    - task: SonarQubePrepare@4

      inputs:

        SonarQube: 'SonarQube-Dev'

        scannerMode: 'MSBuild'

        projectKey: 'Wiired.Card.PauseManagement'

        projectName: 'Wiired.Card.PauseManagement'

          

    - task: DotNetCoreCLI@2

      inputs:

        command: 'build'

        projects: '**/*.sln'   

    - task: SonarQubeAnalyze@4

Want to become Azure Developer, check out this Microsoft Azure Training.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jan 20, 2021 in Azure by dante07 (13.1k points)
0 votes
1 answer
asked Dec 1, 2020 in Azure by Justin (7k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...