.net-core - 'reportgenerator' 不是内部或外部命令,也不是可运行的程序或批处理文件

标签 .net-core azure-devops continuous-integration yaml reportgenerator

当尝试使用“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/

相关文章:

.net-core - .NET 核心 SqlException :an error occurred during the pre-login handshake

azure-devops - Azure Devops 无法使用项目管理员删除积压选项

azure - 来自 "tfx"服务器的 TFX-CLI : is there a way to download task. json?

c# - 命令 '/bin/sh -c dotnet restore ./DockerTestDebian.csproj' 返回非零代码 : 1

c# - 如何使用 native C++的COM实现C#的接口(interface)?

Azure 管道代理无法提取项目并出现错误 : unsupported media type "undefined"

java - 如何删除 Hudson 的构建工件?

java - 有没有办法从命令行配置 Maven POM 的版本?

java - 从长远来看,在 Hudson 和 CruiseControl 之间进行选择

c# - debian 上的 dotnet 核心控制台应用程序 - 查看屏幕上的输出?