Azure DevOps Server 2020 (On-Prem) sonarqube extension can't analyze ASP.net code

Must-share information (formatted with Markdown):

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

We are trying to use SonarQube extension 5.10 for AzureDevOps Server.
Our Application is ASP.net web application

Could you please help to figure out, why it’s failing when code scanning.
Also doubt whether we have to go one level inside the from parent folder.
Thanks.

Application structure is as follow.

image

CI/CD pipeline

Pipeline execution

Error Log

Error Log Text

Starting: Run Code Analysis

Task : Run Code Analysis
Description : Run scanner and upload the results to the SonarQube server.
Version : 5.10.0
Author : sonarsource
Help : Version: 5.10.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

More Information

C:\Users\dhanuka84\agent_work_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.10.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 5.10
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
##[error]02:25:18.34 The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:

  1. The project has not been built - the project must be built in between the begin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  3. The begin, build and end steps have not all been launched from the same folder
  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
    02:25:18.34 The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
    Possible causes:
  5. The project has not been built - the project must be built in between the begin and end steps
  6. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  7. The begin, build and end steps have not all been launched from the same folder
  8. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
    02:25:18.34 Generation of the sonar-properties file failed. Unable to complete the analysis.
    ##[error]02:25:18.356 Post-processing failed. Exit code: 1
    02:25:18.356 Post-processing failed. Exit code: 1
    ##[error]The process ‘C:\Users\dhanuka84\agent_work_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.10.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe’ failed with exit code 1
    Finishing: Run Code Analysis

I have change the project structure and configured the pipeline as YAML file, but same issue

image

Pipeline

pool:
name: Default
demands:

  • msbuild
  • visualstudio
  • vstest
  • java

#Your build pipeline references an undefined variable named ‘Parameters.solution’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See YAML schema reference | Microsoft Learn
#Your build pipeline references an undefined variable named ‘Parameters.solution’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See YAML schema reference | Microsoft Learn
#Your build pipeline references the ‘BuildPlatform’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See YAML schema reference | Microsoft Learn
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See YAML schema reference | Microsoft Learn
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See YAML schema reference | Microsoft Learn
#Your build pipeline references the ‘BuildPlatform’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See YAML schema reference | Microsoft Learn
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See YAML schema reference | Microsoft Learn
#Your build pipeline references an undefined variable named ‘Parameters.ArtifactName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See YAML schema reference | Microsoft Learn

variables:
Parameters.solution: ‘**/*.sln’
buildPlatform: ‘Any CPU’
buildConfiguration: ‘Release’

steps:

  • task: NuGetToolInstaller@0
    displayName: ‘Use NuGet 4.4.1’
    inputs:
    versionSpec: 4.4.1

  • task: NuGetCommand@2
    displayName: ‘NuGet restore’
    inputs:
    restoreSolution: ‘$(Parameters.solution)’

  • task: VSBuild@1
    displayName: ‘Build solution’
    inputs:
    solution: ‘$(Parameters.solution)’
    msbuildArgs: ‘/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=“$(build.artifactstagingdirectory)\”’
    platform: ‘$(BuildPlatform)’
    configuration: ‘$(BuildConfiguration)’

  • task: VSTest@2
    displayName: ‘Test Assemblies’
    inputs:
    testAssemblyVer2: |
    $(BuildConfiguration)*test.dll
    !
    *\obj**
    platform: ‘$(BuildPlatform)’
    configuration: ‘$(BuildConfiguration)’

  • task: sonarsource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@5
    displayName: ‘Prepare analysis on SonarQube’
    inputs:
    SonarQube: ‘zurich-sonarqube’
    projectKey: ‘zurich-poc_FirstWebApp_AYV8BLHZAHlyNzlL_m3H’
    projectName: ASPApp

  • task: sonarsource.sonarqube.6D01813A-9589-4B15-8491-8164AEB38055.SonarQubeAnalyze@5
    displayName: ‘Run Code Analysis’

  • task: sonarsource.sonarqube.291ed61f-1ee4-45d3-b1b0-bf822d9095ef.SonarQubePublish@5
    displayName: ‘Publish Quality Gate Result’

  • task: PublishSymbols@2
    displayName: ‘Publish symbols path’
    inputs:
    SearchPattern: ‘**\bin***.pdb’
    PublishSymbols: false
    continueOnError: true

  • task: PublishBuildArtifacts@1
    displayName: ‘Publish Artifact’
    inputs:
    PathtoPublish: ‘$(build.artifactstagingdirectory)’
    ArtifactName: ‘drop’
    condition: succeededOrFailed()

Oki, found the solution.

we should put it in right order.

1 Like

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