Template for a good new topic, formatted with Markdown:
- ALM used: Azure DevOps
- CI system used: Azure DevOps
- Command in pipeline:
- task: SonarCloudAnalyze@1
- Languages of the repository: C#
- Error observed:
If code coverage report is generated, the above step fails with the below message:
##[error]ERROR: Invalid value of sonar.sources for xxx.xxx.xxx:yyy.yyy.yyy.yyy:zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz
right after Process project properties step.
Below is an extract of the pipeline:
pool:
vmImage: 'windows-latest'
.
.
.
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:OutputPath=$(Build.ArtifactStagingDirectory)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Unit tests
inputs:
command: test
projects: '**/test/*UnitTests/*.csproj'
arguments: '--configuration ${buildConfiguration} --collect "Code Coverage"'
- task: SonarCloudAnalyze@1
displayName: Run code analysis
Below is the redacted log for Run code analysis step:
2022-08-18T05:06:32.2073751Z ##[section]Starting: Run code analysis
2022-08-18T05:06:32.2210657Z ==============================================================================
2022-08-18T05:06:32.2211001Z Task : Run Code Analysis
2022-08-18T05:06:32.2211284Z Description : Run scanner and upload the results to the SonarCloud server.
2022-08-18T05:06:32.2211553Z Version : 1.32.0
2022-08-18T05:06:32.2211733Z Author : sonarsource
2022-08-18T05:06:32.2212319Z Help : Version: 1.32.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.
[More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-for-azure-devops/)
2022-08-18T05:06:32.2212978Z ==============================================================================
2022-08-18T05:06:32.5180791Z [command]D:\a\_tasks\SonarCloudPrepare_xxx\1.29.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
2022-08-18T05:06:32.5763509Z SonarScanner for MSBuild 5.7.2
2022-08-18T05:06:32.5767595Z Using the .NET Framework version of the Scanner for MSBuild
2022-08-18T05:06:32.6277882Z Post-processing started.
2022-08-18T05:06:32.7844436Z Calling the TFS Processor executable...
2022-08-18T05:06:32.9387395Z Attempting to locate the CodeCoverage.exe tool...
2022-08-18T05:06:32.9440201Z Attempting to locate the CodeCoverage.exe tool using setup configuration...
2022-08-18T05:06:33.0048852Z Code coverage command line tool: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
2022-08-18T05:06:33.0264853Z Fetching code coverage report information from TFS...
2022-08-18T05:06:33.0285387Z Attempting to locate a test results (.trx) file...
2022-08-18T05:06:33.0497618Z Looking for TRX files in: D:\a\1\TestResults
2022-08-18T05:06:33.0502351Z No test results files found
2022-08-18T05:06:33.0731843Z Did not find any binary coverage files in the expected location.
2022-08-18T05:06:33.0749952Z Falling back on locating coverage files in the agent temp directory.
2022-08-18T05:06:33.0753154Z Searching for coverage files in D:\a\_temp
2022-08-18T05:06:33.0768915Z All matching files: count=2
2022-08-18T05:06:33.0769789Z D:\a\_temp\xxx\VssAdministrator_WIN-xxx_2022-08-18.05_06_22.coverage
2022-08-18T05:06:33.0770771Z D:\a\_temp\VssAdministrator_WIN-xxx_2022-08-18_05_06_30\In\WIN-xxx\VssAdministrator_WIN-xxx_2022-08-18.05_06_22.coverage
2022-08-18T05:06:33.1359041Z Unique coverage files: count=1
2022-08-18T05:06:33.1359883Z D:\a\_temp\xxx\VssAdministrator_WIN-xxx_2022-08-18.05_06_22.coverage
2022-08-18T05:06:33.2097506Z Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
2022-08-18T05:06:33.2100032Z Args: analyze /output:D:\a\_temp\xxx\VssAdministrator_WIN-xxx_2022-08-18.05_06_22.coveragexml D:\a\_temp\xxx\VssAdministrator_WIN-xxx_2022-08-18.05_06_22.coverage
2022-08-18T05:06:33.2101366Z Working directory: D:\a\_temp\xxx
2022-08-18T05:06:33.2101735Z Timeout (ms):60000
2022-08-18T05:06:33.2102014Z Process id: 6112
2022-08-18T05:06:34.6273853Z Process returned exit code 0
2022-08-18T05:06:34.6284014Z Coverage report conversion completed successfully.
2022-08-18T05:06:34.6457486Z The TFS Processor has finished
2022-08-18T05:06:34.6515594Z Calling the SonarScanner CLI...
2022-08-18T05:06:35.9657955Z INFO: Scanner configuration file: D:\a\_tasks\SonarCloudPrepare_xxx\1.29.0\classic-sonar-scanner-msbuild\sonar-scanner-4.7.0.2747\bin\..\conf\sonar-scanner.properties
2022-08-18T05:06:35.9681933Z INFO: Project root configuration file: D:\a\1\.sonarqube\out\sonar-project.properties
2022-08-18T05:06:36.1610618Z INFO: SonarScanner 4.7.0.2747
2022-08-18T05:06:36.1613153Z INFO: Java 11.0.16 Eclipse Adoptium (64-bit)
2022-08-18T05:06:36.1613513Z INFO: Windows Server 2022 10.0 amd64
2022-08-18T05:06:37.4969805Z INFO: User cache: C:\Users\VssAdministrator\.sonar\cache
2022-08-18T05:06:43.7287420Z INFO: Scanner configuration file: D:\a\_tasks\SonarCloudPrepare_xxx\1.29.0\classic-sonar-scanner-msbuild\sonar-scanner-4.7.0.2747\bin\..\conf\sonar-scanner.properties
2022-08-18T05:06:43.7292962Z INFO: Project root configuration file: D:\a\1\.sonarqube\out\sonar-project.properties
2022-08-18T05:06:43.7380744Z INFO: Analyzing on SonarCloud
2022-08-18T05:06:43.7382777Z INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
2022-08-18T05:06:44.9179326Z INFO: Load global settings
2022-08-18T05:06:46.3602538Z INFO: Load global settings (done) | time=1439ms
2022-08-18T05:06:46.3743762Z INFO: Server id: xxx
2022-08-18T05:06:46.3975093Z INFO: User cache: C:\Users\VssAdministrator\.sonar\cache
2022-08-18T05:06:46.4138071Z INFO: Load/download plugins
2022-08-18T05:06:46.4139182Z INFO: Load plugins index
2022-08-18T05:06:47.8424177Z INFO: Load plugins index (done) | time=1424ms
2022-08-18T05:07:00.2793974Z INFO: Load/download plugins (done) | time=13873ms
2022-08-18T05:07:02.3867311Z INFO: Loaded core extensions: developer-scanner
2022-08-18T05:07:03.3101524Z INFO: Found an active CI vendor: 'Azure DevOps'
2022-08-18T05:07:03.3349951Z INFO: Load project settings for component key: 'xxx'
2022-08-18T05:07:04.7094742Z INFO: Load project settings for component key: 'xxx' (done) | time=1373ms
2022-08-18T05:07:04.7251625Z INFO: Process project properties
2022-08-18T05:07:04.7492627Z ##[error]ERROR: Invalid value of sonar.sources for xxx:xxx:xxx
2022-08-18T05:07:04.7497389Z ERROR: Invalid value of sonar.sources for xxx:xxx:xxx
2022-08-18T05:07:04.8283061Z INFO: ------------------------------------------------------------------------
2022-08-18T05:07:04.8284068Z INFO: EXECUTION FAILURE
2022-08-18T05:07:04.8284582Z INFO: ------------------------------------------------------------------------
2022-08-18T05:07:04.8285119Z INFO: Total time: 28.908s
2022-08-18T05:07:04.8870688Z INFO: Final Memory: 7M/27M
2022-08-18T05:07:04.8871436Z INFO: ------------------------------------------------------------------------
2022-08-18T05:07:04.8872879Z ##[error]ERROR: Error during SonarScanner execution
2022-08-18T05:07:04.8874807Z ERROR: Error during SonarScanner execution
2022-08-18T05:07:04.8880648Z ##[error]ERROR: The folder 'D:\a\1\s\src\xxx\obj\\net6.0\.NETCoreApp,Version=v6.0.AssemblyAttributes.cs' does not exist for 'xxx:xxx:xxx' (base directory = D:\a\1\s\src\xxx)
2022-08-18T05:07:04.8884634Z ERROR: The folder 'D:\a\1\s\src\xxx\obj\\net6.0\.NETCoreApp,Version=v6.0.AssemblyAttributes.cs' does not exist for 'xxx:xxx:xxx' (base directory = D:\a\1\s\src\xxx)
2022-08-18T05:07:04.8886829Z ##[error]ERROR:
2022-08-18T05:07:04.8888319Z ERROR:
2022-08-18T05:07:05.4280058Z ##[error]The SonarScanner did not complete successfully
2022-08-18T05:07:05.4282761Z The SonarScanner did not complete successfully
2022-08-18T05:07:05.4283972Z ##[error]05:07:05.417 Post-processing failed. Exit code: 1
2022-08-18T05:07:05.4285230Z 05:07:05.417 Post-processing failed. Exit code: 1
2022-08-18T05:07:05.4435239Z ##[error]The process 'D:\a\_tasks\SonarCloudPrepare_xxx\1.29.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2022-08-18T05:07:05.4504070Z ##[section]Finishing: Run code analysis
If I comment out the tests step (VSBuild@1
), code analysis runs with no problem and publishes the report to Quality Gate successfully, with a code coverage of 0%.