When trying to create a report using 'ReportGenerator' tool as part of Azure devops YAML pipleine, below error is being thrown though i installed the tool in previous step.
- script: dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.6.1
displayName: 'Install ReportGenerator tool'
continueOnError: true
- script: reportgenerator "-reports:$(Agent.TempDirectory)/**/*.cobertura.xml" "-targetdir:$(Build.SourcesDirectory)/coverlet/reports" -reporttypes:Cobertura;htmlInline
displayName: Generate code coverage report
continueOnError: true
Error : 'reportgenerator' is not recognized as an internal or external command,
operable program or batch file.
##[error]Cmd.exe exited with code '1'.
Adding logs
Install Step:
Script contents:
dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools --version 4.6.1
========================== Starting Command Output ===========================
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "E:\Agent_work\_temp\d9535a65-152b-4822-a4f2-7e58c11f2418.cmd""
You can invoke the tool using the following command: reportgenerator
Tool 'dotnet-reportgenerator-globaltool' (version '4.6.1') was successfully installed.
Finishing: Install ReportGenerator tool
Executing tool :
Script contents:
reportgenerator "-reports:E:\Agent_work\_temp/**/*.cobertura.xml" "-targetdir:E:\Agent_work\79\s/coverlet/reports" -reporttypes:Cobertura;htmlInline
========================== Starting Command Output ===========================
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "E:\Agent_work\_temp\53dbc699-e878-4458-aaf2-8e69e5c4f09a.cmd""
'reportgenerator' is not recognized as an internal or external command,
operable program or batch file.
##[error]Cmd.exe exited with code '1'.
There is a known bug when you are trying to do that on Linux machine. After report generator installation, please try to add this additional step to update the PATH:
- script: echo "##vso[task.prependpath]$HOME/.dotnet/tools"
So the whole solution looks like this:
- task: DotNetCoreCLI@2
displayName: Install ReportGenerator Global Tool
inputs:
command: custom
custom: tool
arguments: install dotnet-reportgenerator-globaltool -g
- script: echo "##vso[task.prependpath]$HOME/.dotnet/tools"
displayName: 'Update PATH'
- script: reportgenerator "-reports:$(Agent.TempDirectory)/**/*.cobertura.xml" "-targetdir:$(Build.SourcesDirectory)/coverlet/reports" -reporttypes:Cobertura;htmlInline
displayName: Generate code coverage report
continueOnError: true
The following YAML file should do the job:
- script: dotnet tool install --tool-path tools dotnet-reportgenerator-globaltool --version 4.6.1
displayName: 'Install ReportGenerator tool'
continueOnError: true
- script: ./tools/reportgenerator "-reports:$(Agent.TempDirectory)/**/*.cobertura.xml" "-targetdir:$(Build.SourcesDirectory)/coverlet/reports" "-reporttypes:Cobertura;HtmlInline"
You can also use the Azure DevOps extension:
https://marketplace.visualstudio.com/items?itemName=Palmmedia.reportgenerator
Usage:
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
displayName: ReportGenerator
inputs:
reports: '$(Agent.TempDirectory)/**/*.cobertura.xml'
targetdir: '$(Build.SourcesDirectory)/coverlet/reports'
reporttypes: 'Cobertura;HtmlInline'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With