as the title suggests, i'm trying to get the code coverage to work on Azure Devops Pipeline.
This is the pipeline:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Installing .NET Core SDK...'
inputs:
version: 3.1.101
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'Building $(buildConfiguration)...'
- task: DotNetCoreCLI@2
displayName: 'Executing dotnet tests...'
inputs:
command: test
arguments: '--configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)\TestResults\Coverage\'
projects: '**/*Test/*.csproj'
nobuild: true
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:$(Build.SourcesDirectory)\TestResults\Coverage\coverage.cobertura.xml - targetdir:$(Build.SourcesDirectory)\CodeCoverage -reporttypes:HtmlInline_AzurePipelines;Cobertura
displayName: 'Creating code coverage report...'
- task: PublishCodeCoverageResults@1
displayName: 'Publishing code coverage...'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)\CodeCoverage\Cobertura.xml'
reportDirectory: '$(Build.SourcesDirectory)\CodeCoverage'
My solution contains a front-end project and a xunit test project with the name ending in "Test".
Tests are running just fine but i always get an error at this line:
reportgenerator -reports:$(Build.SourcesDirectory)\TestResults\Coverage\coverage.cobertura.xml ...
With the actual pipeline the error is:
The report file 'D:\a\1\s\TestResults\Coverage\coverage.cobertura.xml' is invalid. File does not exist (Full path: 'D:\a\1\s\TestResults\Coverage\coverage.cobertura.xml').
I tried to generate test reports locally on my pc and it works just fine. It means that the packages are ok.
What i'm doing wrong?