当尝试使用“ReportGenerator”工具作为 Azure devops YAML 管道的一部分创建报告时,
尽管我在上一步安装了该工具,但仍抛出以下错误。
- 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
错误:“reportgenerator”未被识别为内部或外部命令,可运行的程序或批处理文件。
##[error]Cmd.exe 退出,代码为“1”。
添加日志
安装步骤:
脚本内容:
dotnet 工具安装 dotnet-reportgenerator-globaltool --tool-path 工具 --version 4.6.1
========================== 开始命令输出 ====================== ======
"C:\windows\system32\cmd.exe"/D/E:ON/V:OFF/S/C "CALL "E:\Agent_work_temp\d9535a65-152b-4822-a4f2-7e58c11f2418.cmd""
您可以使用以下命令调用该工具:reportgenerator
工具“dotnet-reportgenerator-globaltool”(版本“4.6.1”)已成功安装。
整理:安装 ReportGenerator 工具
执行工具:
脚本内容:
报告生成器 "-reports:E:\Agent_work_temp/**/*.cobertura.xml""-targetdir:E:\Agent_work\79\s/coverlet/reports"-reporttypes:Cobertura;htmlInline
========================== 开始命令输出 ====================== ======
"C:\windows\system32\cmd.exe"/D/E:ON/V:OFF/S/C "CALL "E:\Agent_work_temp\53dbc699-e878-4458-aaf2-8e69e5c4f09a.cmd""
'reportgenerator' 未被识别为内部或外部命令,
可运行的程序或批处理文件。
##[error]Cmd.exe 退出,代码为“1”。
最佳答案
有a known bug当您尝试在 Linux 机器上执行此操作时。安装报告生成器后,请尝试添加此附加步骤以更新 PATH:
- script: echo "##vso[task.prependpath]$HOME/.dotnet/tools"
所以整个解决方案如下所示:- 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
关于.net-core - 'reportgenerator' 不是内部或外部命令,也不是可运行的程序或批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62705105/