SonarScanner for Azure Devops MSBuild Integrated not able to find my source code

ALM - Azure Devops
CI - Azure Devops
Lang - C#, .Net, Desktop App

My YML file:
‘’’
trigger:
- master

    pool:
    vmImage: 'windows-latest'
    variables:
    solution: '**/*.sln'
    buildPlatform: 'Any CPU'
    buildConfiguration: 'Release'

   steps:
   - checkout: self
   lfs: true

   - task: NuGetToolInstaller@1

   - task: NuGetCommand@2
   inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'select'
    noCache: true

    - task: SonarCloudPrepare@1
    inputs:
    SonarCloud: 'SonarCloud'
    organization: '************'
    scannerMode: 'MSBuild'
    projectKey: '*************'
    projectName: '**************'
    extraProperties: |
      sonar.verbose=true

    - task: VSBuild@1
    inputs:
    solution: '$(solution)'
    vsVersion: '16.0'
    msbuildArgs: '/t:restore /p:nugetInteractive=true'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    clean: true
    msbuildArchitecture: 'x64'

    - task: SonarCloudAnalyze@1

    - task: SonarCloudPublish@1
    inputs:
    pollingTimeoutSec: '300'

‘’’
With this code I get the following errors when the Scanner tries to Analyze the code:

'''D:\a\_tasks\SonarCloudPrepare_***********\1.18.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end

SonarScanner for MSBuild 5.2

Using the .NET Framework version of the Scanner for MSBuild

Post-processing started.

13:39:38.012 13:39:38.012 sonar.verbose=true was specified - setting the log verbosity to 'Debug'

13:39:38.017 Loading the SonarCloud analysis config from D:\a\1\.sonarqube\conf\SonarQubeAnalysisConfig.xml

13:39:38.017 TeamBuild environment detected

13:39:38.017 Analysis base directory: D:\a\1\.sonarqube

Build directory: D:\a\1

Bin directory: D:\a\1\.sonarqube\bin

Config directory: D:\a\1\.sonarqube\conf

Output directory: D:\a\1\.sonarqube\out

Config file: D:\a\1\.sonarqube\conf\SonarQubeAnalysisConfig.xml

13:39:38.042 Generating SonarCloud project properties file to D:\a\1\.sonarqube\out\sonar-project.properties

##[error]13:39:38.048 The SonarScanner for MSBuild integration failed: SonarCloud 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)

13:39:38.048 The SonarScanner for MSBuild integration failed: SonarCloud 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)

13:39:38.048 Generation of the sonar-properties file failed. Unable to complete the analysis.

13:39:38.057 Writing processing summary to D:\a\1\.sonarqube\out\ProjectInfo.log

##[error]13:39:38.058 Post-processing failed. Exit code: 1

13:39:38.058 Post-processing failed. Exit code: 1

##[error]The process 'D:\a\_tasks\SonarCloudPrepare_**********\1.18.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1

Finishing: SonarCloudAnalyze'''

Steps to Reproduce:
See YML file.

From the error it looks like the SonarScanner is trying to scan in the wrong directory, so I tried adding the scanner.sources variable and point it to the correct path, but it still doesn’t scan in the correct location.

What are we doing wrong, and how do we get the scanner to scan our source code?

I haven’t been able to find any workaround or suitable documentation/solution to this issue, and we have been working on this for 3 days.

Hi @jbrecker and welcome to the community !

Can you share the SonarCloudPrepare step log as well please ?

Thanks.

1 Like

Here is the prepare log:
2021-04-13T13:39:14.3879784Z ##[section]Starting: SonarCloudPrepare
2021-04-13T13:39:14.4019845Z ==============================================================================
2021-04-13T13:39:14.4020268Z Task : Prepare Analysis Configuration
2021-04-13T13:39:14.4020578Z Description : Prepare SonarCloud analysis configuration
2021-04-13T13:39:14.4020813Z Version : 1.18.0
2021-04-13T13:39:14.4021011Z Author : sonarsource
2021-04-13T13:39:14.4021426Z Help : Version: 1.18.0. More Information
2021-04-13T13:39:14.4021865Z ==============================================================================
2021-04-13T13:39:15.2493164Z SYSTEMVSSCONNECTION exists true
2021-04-13T13:39:15.8147280Z [command]D:\a_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.18.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:******** /o:*********
2021-04-13T13:39:15.8971919Z SonarScanner for MSBuild 5.2
2021-04-13T13:39:15.8973014Z Using the .NET Framework version of the Scanner for MSBuild
2021-04-13T13:39:15.9518465Z Pre-processing started.
2021-04-13T13:39:15.9549271Z Preparing working directories…
2021-04-13T13:39:16.2724136Z 13:39:16.27 13:39:16.258 Loading analysis properties from D:\a_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.18.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2021-04-13T13:39:16.2725308Z 13:39:16.271 13:39:16.27 sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
2021-04-13T13:39:16.5911679Z 13:39:16.589 Updating build integration targets…
2021-04-13T13:39:16.5979456Z 13:39:16.597 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
2021-04-13T13:39:16.5990184Z 13:39:16.598 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
2021-04-13T13:39:16.6003410Z 13:39:16.599 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
2021-04-13T13:39:16.6036892Z 13:39:16.6 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
2021-04-13T13:39:16.6038667Z 13:39:16.602 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
2021-04-13T13:39:16.6043949Z 13:39:16.603 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
2021-04-13T13:39:16.6056929Z 13:39:16.604 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\VssAdministrator\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
2021-04-13T13:39:16.6067052Z 13:39:16.605 Installed SonarQube.Integration.targets to D:\a\1.sonarqube\bin\targets
2021-04-13T13:39:16.6079524Z 13:39:16.607 Creating config and output folders…
2021-04-13T13:39:16.6093877Z 13:39:16.608 Creating directory: D:\a\1.sonarqube\conf
2021-04-13T13:39:16.6096187Z 13:39:16.608 Creating directory: D:\a\1.sonarqube\out
2021-04-13T13:39:16.6418001Z 13:39:16.64 Downloading from ____://sonarcloud.io/api/server/version…
2021-04-13T13:39:17.4379819Z 13:39:17.436 SonarCloud detected, skipping license check.
2021-04-13T13:39:17.4453621Z 13:39:17.444 Fetching analysis configuration settings…
2021-04-13T13:39:17.4522953Z 13:39:17.451 Fetching properties for project '’ from ____://sonarcloud.io/api/settings/values?component=
2021-04-13T13:39:17.4566331Z 13:39:17.455 Downloading from ____://sonarcloud.io/api/settings/values?component=
2021-04-13T13:39:17.6853261Z 13:39:17.682 Downloading from ____://sonarcloud.io/api/languages/list…
2021-04-13T13:39:17.8467172Z 13:39:17.845 Fetching quality profile for project '
’ from ____://sonarcloud.io/api/qualityprofiles/search?project=**&organization=
2021-04-13T13:39:17.8501938Z 13:39:17.849 Downloading from ____://sonarcloud.io/api/qualityprofiles/search?project=
&organization=
2021-04-13T13:39:18.0657535Z 13:39:18.061 Fetching rules for quality profile ‘AXi23FJOIxA1NhKfxZSr’ from ____://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXi23FJOIxA1NhKfxZSr&p=1…
2021-04-13T13:39:18.0659707Z 13:39:18.063 Downloading from ____://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXi23FJOIxA1NhKfxZSr&p=1…
2021-04-13T13:39:18.6180389Z 13:39:18.617 Local analyzer cache: C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources
2021-04-13T13:39:18.6310764Z 13:39:18.626 Writing Roslyn generated ruleset to D:\a\1.sonarqube\conf\Sonar-cs.ruleset…
2021-04-13T13:39:18.6500252Z 13:39:18.642 Writing Roslyn generated ruleset to D:\a\1.sonarqube\conf\Sonar-cs-none.ruleset…
2021-04-13T13:39:18.6501292Z 13:39:18.647 Provisioning analyzer assemblies for cs…
2021-04-13T13:39:18.6501875Z 13:39:18.648 Installing required Roslyn analyzers…
2021-04-13T13:39:18.6505039Z 13:39:18.649 Processing plugin: csharp version 8.20.0.28934
2021-04-13T13:39:18.7695508Z 13:39:18.768 Cache miss: plugin files were not found in the local cache
2021-04-13T13:39:18.8131784Z 13:39:18.812 Fetching resource for plugin: csharp, version 8.20.0.28934. Resource: SonarAnalyzer-8.20.0.28934.zip
2021-04-13T13:39:18.8184188Z 13:39:18.817 Downloading SonarAnalyzer-8.20.0.28934.zip from ____://sonarcloud.io/static/csharp/SonarAnalyzer-8.20.0.28934.zip to C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\0
2021-04-13T13:39:18.8220487Z 13:39:18.821 Downloading file from ____://sonarcloud.io/static/csharp/SonarAnalyzer-8.20.0.28934.zip to C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\0\SonarAnalyzer-8.20.0.28934.zip…
2021-04-13T13:39:19.5933844Z 13:39:19.592 Extracting files to C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\0…
2021-04-13T13:39:19.6920216Z 13:39:19.69 Processing plugin: vbnet version 8.20.0.28934
2021-04-13T13:39:19.7249746Z 13:39:19.723 Cache miss: plugin files were not found in the local cache
2021-04-13T13:39:19.7250615Z 13:39:19.723 Fetching resource for plugin: vbnet, version 8.20.0.28934. Resource: SonarAnalyzer-8.20.0.28934.zip
2021-04-13T13:39:19.7251478Z 13:39:19.723 Downloading SonarAnalyzer-8.20.0.28934.zip from ____://sonarcloud.io/static/vbnet/SonarAnalyzer-8.20.0.28934.zip to C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\1
2021-04-13T13:39:19.7252718Z 13:39:19.723 Downloading file from ____://sonarcloud.io/static/vbnet/SonarAnalyzer-8.20.0.28934.zip to C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\1\SonarAnalyzer-8.20.0.28934.zip…
2021-04-13T13:39:19.8920962Z 13:39:19.889 Extracting files to C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\1…
2021-04-13T13:39:19.9098053Z 13:39:19.908 Processing plugin: securitycsharpfrontend version 8.9.0-M1.10592
2021-04-13T13:39:19.9106559Z 13:39:19.909 Cache miss: plugin files were not found in the local cache
2021-04-13T13:39:19.9108138Z 13:39:19.909 Fetching resource for plugin: securitycsharpfrontend, version 8.9.0-M1.10592. Resource: SonarAnalyzer.Security-8.9.0-M1.10592.zip
2021-04-13T13:39:19.9109579Z 13:39:19.909 Downloading SonarAnalyzer.Security-8.9.0-M1.10592.zip from ____://sonarcloud.io/static/securitycsharpfrontend/SonarAnalyzer.Security-8.9.0-M1.10592.zip to C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\2
2021-04-13T13:39:19.9111252Z 13:39:19.909 Downloading file from ____://sonarcloud.io/static/securitycsharpfrontend/SonarAnalyzer.Security-8.9.0-M1.10592.zip to C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\2\SonarAnalyzer.Security-8.9.0-M1.10592.zip…
2021-04-13T13:39:20.0771940Z 13:39:20.075 Extracting files to C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\2…
2021-04-13T13:39:20.1291472Z 13:39:20.127 Writing Roslyn analyzer additional file to D:\a\1.sonarqube\conf\cs\SonarLint.xml…
2021-04-13T13:39:20.1315173Z 13:39:20.128 Fetching quality profile for project '
’ from ____://sonarcloud.io/api/qualityprofiles/search?project=&organization=
2021-04-13T13:39:20.1316356Z 13:39:20.128 Downloading from ____://sonarcloud.io/api/qualityprofiles/search?project=
&organization=*********…
2021-04-13T13:39:20.3240017Z 13:39:20.32 Fetching rules for quality profile ‘AXi23FJOIxA1NhKfxZSd’ from ____://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXi23FJOIxA1NhKfxZSd&p=1…
2021-04-13T13:39:20.3251586Z 13:39:20.32 Downloading from ____://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXi23FJOIxA1NhKfxZSd&p=1…
2021-04-13T13:39:20.5186735Z 13:39:20.517 Local analyzer cache: C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources
2021-04-13T13:39:20.5187604Z 13:39:20.517 Writing Roslyn generated ruleset to D:\a\1.sonarqube\conf\Sonar-vbnet.ruleset…
2021-04-13T13:39:20.5215762Z 13:39:20.518 Writing Roslyn generated ruleset to D:\a\1.sonarqube\conf\Sonar-vbnet-none.ruleset…
2021-04-13T13:39:20.5219019Z 13:39:20.519 Provisioning analyzer assemblies for vbnet…
2021-04-13T13:39:20.5219632Z 13:39:20.519 Installing required Roslyn analyzers…
2021-04-13T13:39:20.5220221Z 13:39:20.519 Processing plugin: csharp version 8.20.0.28934
2021-04-13T13:39:20.5220895Z 13:39:20.52 Cache hit: using plugin files from C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\0
2021-04-13T13:39:20.5221577Z 13:39:20.52 Processing plugin: vbnet version 8.20.0.28934
2021-04-13T13:39:20.5222226Z 13:39:20.521 Cache hit: using plugin files from C:\Users\VssAdministrator\AppData\Local\Temp.sonarqube\resources\1
2021-04-13T13:39:20.5225522Z 13:39:20.521 Writing Roslyn analyzer additional file to D:\a\1.sonarqube\conf\vbnet\SonarLint.xml…
2021-04-13T13:39:20.5647411Z 13:39:20.563 Pre-processing succeeded.
2021-04-13T13:39:20.5895681Z ##[section]Finishing: SonarCloudPrepare

Thanks so it appears that targets are correctly installed.

By chance do you have any /p:RunAnalyzers=false or RunAnalyzersDuringBuild properties set in your build step ?

Can you share also your build logs, if possible in detailed verbose mode ? I can PM you if you want to share them privately, let me know.

Thanks.

I am working on getting that for you. Yes please PM me so I can send this to you directly.

No to both of those parameters mentioned. This is my first time trying to integrate with SonarCloud using Azure Devops pipelines.

We figured this out with Mickael’s help.

Our gitignore was not configured correctly and too many files were being included in the commits and the pipeline builds were failing.

1 Like

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