We are using Azure Devops Build pipeline to submit code for analysis to SonarCloud.
This works out of the box for building our .NET Framework solutions, but I currently cannot see it working correctly for .NET Core.
We have the following azure pipline config:
-
task: SonarCloudPrepare@1
displayName: “Prepare SonarCloud”
inputs:
SonarCloud: ‘SonarCloudName’
organization: ‘OrgName’
scannerMode: ‘MSBuild’
projectKey: ‘(projectName)' projectName: '(projectName)’
projectVersion: ‘$(Build.BuildNumber)’ -
task: DotNetCoreCLI@2
inputs:
arguments: --no-restore --configuration (BuildConfiguration) --output (Build.ArtifactStagingDirectory)
projects: $(solutionSubDirectory)/Example.csproj
command: ‘publish’
publishWebProjects: false
zipAfterPublish: true -
task: VSTest@2
displayName: “Run Unit Tests”
inputs:
testSelector: ‘testAssemblies’
testAssemblyVer2: |
ExamplePath\UnitTests.dll
searchFolder: ‘$(System.DefaultWorkingDirectory)’ -
task: SonarCloudAnalyze@1
The pipeline successfully passes, and we can see the branch has run within SonarCloud, and a quality gate assigned, however, there are no issues. When you browse to the “Code” tab in SonarCloud it’s empty (to me, this suggests it’s not successfully uploaded the files correctly?)
Output for the “PrepareSonarCloud” step:
SonarScanner for MSBuild 4.7.1
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories…
12:33:27.015 Updating build integration targets…
12:33:27.031 Fetching analysis configuration settings…
12:33:29.353 Provisioning analyzer assemblies for cs…
12:33:29.353 Installing required Roslyn analyzers…
12:33:31.06 Provisioning analyzer assemblies for vbnet…
12:33:31.06 Installing required Roslyn analyzers…
12:33:31.091 Pre-processing succeeded.
##[section]Finishing: Prepare SonarCloud
The SonarCloudAnalyze stage output:
SonarScanner for MSBuild 4.7.1
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
12:34:07.271 Fetching code coverage report information from TFS…
12:34:07.271 Attempting to locate a test results (.trx) file…
12:34:07.287 Looking for TRX files in: d:\a\1\TestResults
12:34:07.287 No test results files found
12:34:07.287 Did not find any binary coverage files in the expected location.
12:34:07.287 Falling back on locating coverage files in the agent temp directory.
12:34:07.287 Searching for coverage files in d:\a_temp
12:34:07.287 No coverage files found in the agent temp directory.
Calling the SonarQube Scanner…
INFO: Project root configuration file: d:\a\1.sonarqube\out\sonar-project.properties
INFO: SonarQube Scanner 4.1.0.1829
INFO: Java 1.8.0_222 Azul Systems, Inc. (64-bit)
INFO: Windows Server 2019 10.0 amd64
INFO: User cache: C:\Users\VssAdministrator.sonar\cache
INFO: SonarQube server 8.0.0
…
…
INFO: Indexing files…
…
…
INFO: Base dir: D:\a\1\s
INFO: 85 files indexed
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for cs: Sonar way
So to me it looks like it is finding and processing it correctly, but I’m not seeing the output in SonarCloud as I would expect?
Any ideas on what I may have missed would be greatly appreciated
NB: I have already had to add a ProjectGuid to my .csproj files in order to get to this “successfully” passing stage.
Thank you in advance for anyones time!