Hello, I have a problem coverage does not appear. However, the .trx and Cobertura.xml files are created correctly. Why does my process look the way it does? The first machine can run integration tests with the database (but send sonar is blocked in this machine), and the second machine has no access to the database in the company network but is in Azure, and it is possible to connect to sonar. The second machine downloads the test results from the artifacts, and the files are downloaded. However, coverage does not appear in the sonar cloud.
The worst part is that it looks good and should work.
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
trigger:
- master
- develop
stages:
- stage: build
jobs:
- job: A
pool:
name: 'On-site pipelines'
demands: Dotnet.Version -equals 6.0.0
variables:
configuration: release
npm_config_cache: $(Pipeline.Workspace)/.npm
SolutionDir: '..\.\'
steps:
- task: DotNetCoreCLI@2
displayName: Restore NuGet Packages
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'config'
nugetConfigPath: './nuget.config'
- task: NuGetToolInstaller@1
inputs:
versionSpec:
checkLatest: true
- task: DotNetCoreCLI@2
displayName: Build .Net Core Projects
inputs:
command: 'build'
projects: |
**/*.csproj
arguments: '--runtime win-x64'
- task: DotNetCoreCLI@2
displayName: Run Tests
inputs:
command: 'test'
projects: '**/*.Tests*.csproj'
nobuild: true
arguments: '--configuration $(configuration) --collect:"Code Coverage" /p:Exclude="[*Tests*]*"'
- task: DotNetCoreCLI@2
displayName: "dotnet test"
inputs:
command: 'test'
projects: 'Backend\App\App.sln'
publishTestResults: true
arguments: --no-restore --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
- task: reportgenerator@4
displayName: "Merge code coverage reports"
inputs:
reports: "**/coverage.cobertura.xml"
targetdir: "$(Build.ArtifactStagingDirectory)/coverlet"
reporttypes: "Cobertura"
verbosity: "Verbose"
- task: PublishPipelineArtifact@1
displayName: Publish Artifacts from output folder
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/coverlet'
artifact: 'Cobertura'
publishLocation: 'pipeline'
- task: PublishPipelineArtifact@1
displayName: Publish Artifacts for sonar
inputs:
targetPath: 'F:\agent\_temp\'
artifact: 'AIDA_SONAR_TRX'
publishLocation: 'pipeline'
- stage: build_sonar
jobs:
- job: B
pool:
vmImage: 'windows-latest'
variables:
configuration: release
npm_config_cache: $(Pipeline.Workspace)/.npm
SolutionDir: '..\.\'
steps:
- task: NuGetToolInstaller@1
inputs:
versionSpec: 6.0.0
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'AIDA_SONAR_TRX'
targetPath: 'D:/a/_temp'
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'Cobertura'
targetPath: 'D:/a/_temp'
- task: DotNetCoreCLI@2
displayName: Restore NuGet Packages
inputs:
command: 'restore'
projects: |
**/Connectors.App.csproj
feedsToUse: 'config'
nugetConfigPath: './nuget.config'
- task: SonarCloudPrepare@1
displayName: 'Prepare SonarCloud analysis'
inputs:
SonarCloud: 'XXX'
organization: 'XXX'
scannerMode: 'MSBuild'
projectKey: 'XXX'
projectName: 'XXX'
extraProperties: |
sonar.cs.cobertura.reportsPaths=D:\a\_temp\Cobertura.xml
sonar.cs.vstest.reportsPaths=D:\a\_temp\*.trx
- task: DotNetCoreCLI@2
displayName: Build .Net Core Projects
inputs:
command: 'build'
projects: |
**/*.csproj
arguments: '--runtime win-x64 --no-restore --self-contained false'
- task: CopyFiles@2
displayName: Copy backend build files to output folder
inputs:
SourceFolder: '$(Build.SourcesDirectory)/Backend/App/RuntimeWeb'
Contents: '**'
TargetFolder: '$(Build.SourcesDirectory)/build/Backend'
- task: SonarCloudAnalyze@1
displayName: 'Run SonarCloud code analysis'
- task: SonarCloudPublish@1
displayName: 'Publish SonarCloud quality gate results'
inputs:
pollingTimeoutSec: '300'