.net core ';报表生成器';未被识别为内部或外部命令、可操作程序或批处理文件
当尝试使用“ReportGenerator”工具作为Azure devops YAML pipleine的一部分创建报告时, 虽然我在上一步中安装了该工具,但仍引发以下错误.net core ';报表生成器';未被识别为内部或外部命令、可操作程序或批处理文件,.net-core,azure-devops,continuous-integration,yaml,reportgenerator,.net Core,Azure Devops,Continuous Integration,Yaml,Reportgenerator,当尝试使用“ReportGenerator”工具作为Azure devops YAML pipleine的一部分创建报告时, 虽然我在上一步中安装了该工具,但仍引发以下错误 - script: dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.6.1 displayName: 'Install ReportGenerator tool' continueOnError: true - s
- 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”未被识别为内部或外部命令,
可操作的程序或批处理文件。
##[错误]Cmd.exe已退出,代码为“1”
添加日志
安装步骤:
脚本内容:
dotnet工具安装dotnet reportgenerator globaltool--工具路径工具--版本4.6.1
=====================================启动命令输出===========================
“C:\windows\system32\cmd.exe”/D/E:ON/V:OFF/S/C“调用”E:\Agent\u work\u temp\d9535a65-152b-4822-a4f2-7e58c11f2418.cmd”
您可以使用以下命令调用该工具:reportgenerator
已成功安装工具“dotnet reportgenerator globaltool”(版本“4.6.1”)。
完成:安装ReportGenerator工具
执行工具:
脚本内容:
reportgenerator“-报告:E:\Agent\u work\u temp/***.cobertura.xml”“-targetdir:E:\Agent\u work\79\s/coverlet/reports”-报告类型:cobertura;HTMLINE
=====================================启动命令输出===========================
“C:\windows\system32\cmd.exe”/D/E:ON/V:OFF/S/C“调用”E:\Agent\u work\u temp\53dbc699-e878-4458-aaf2-8e69e5c4f09a.cmd”
“reportgenerator”未被识别为内部或外部命令,
可操作的程序或批处理文件。
##[错误]Cmd.exe已退出,代码为“1”。在Linux计算机上尝试执行此操作时会出现错误。安装报表生成器后,请尝试添加此附加步骤以更新路径:
- 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
这是因为您使用的是自托管代理。在代理上安装新软件后,必须重新启动代理才能在池中显示新功能,以便生成可以运行
只需转到代理计算机上的任务管理器并重新启动生成代理服务。以下YAML文件应该可以完成此任务:
- 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"
您还可以使用Azure DevOps扩展:用法:
- 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'
谢谢你的及时回复。但这不起作用。同样的错误奇怪,我还更新了第一步,用
DotNetCoreCLI
task安装报表生成器。请试一试。它正在我的设置中工作。我正在使用ubuntu最新版本作为vmImage。如果不起作用,请粘贴完整的yaml文件和生成输出,当然没有敏感数据。您是否尝试重新启动生成代理服务?你的问题解决了吗?