使用teamcity上的cake构建运行ReportGenerator(Exec格式错误)



我正试图在项目构建完成后生成测试覆盖率报告并查看teamcity。到目前为止,我已经能够让它在我的本地机器(窗口(上工作,没有任何问题。报告正在生成,我可以查看覆盖率报告(生成的html文件(,但它在teamcity(使用linux代理构建项目(上失败,错误如下:

Error: System.AggregateException: One or more errors occurred. (Exec format error)
---> System.ComponentModel.Win32Exception (8): Exec format error
at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Cake.Core.IO.ProcessRunner.Start(FilePath filePath, ProcessSettings settings) in C:projectscakesrcCake.CoreIOProcessRunner.cs:line 67
at Cake.Core.Tooling.Tool`1.RunProcess(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings) in C:projectscakesrcCake.CoreToolingTool.cs:line 215
at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction) in C:projectscakesrcCake.CoreToolingTool.cs:line 101
at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments) in C:projectscakesrcCake.CoreToolingTool.cs:line 81
at Cake.Common.Tools.ReportGenerator.ReportGeneratorRunner.Run(IEnumerable`1 reports, DirectoryPath targetDir, ReportGeneratorSettings settings) in C:projectscakesrcCake.CommonToolsReportGeneratorReportGeneratorRunner.cs:line 66
at Cake.Common.Tools.ReportGenerator.ReportGeneratorAliases.ReportGenerator(ICakeContext context, IEnumerable`1 reports, DirectoryPath targetDir, ReportGeneratorSettings settings) in C:projectscakesrcCake.CommonToolsReportGeneratorReportGeneratorAliases.cs:line 151
at Cake.Common.Tools.ReportGenerator.ReportGeneratorAliases.ReportGenerator(ICakeContext context, String pattern, DirectoryPath targetDir, ReportGeneratorSettings settings) in C:projectscakesrcCake.CommonToolsReportGeneratorReportGeneratorAliases.cs:line 71
at Submission#0.ReportGenerator(String pattern, DirectoryPath targetDir, ReportGeneratorSettings settings) in :line 356
at Submission#0.<<Initialize>>b__0_4() in /opt/buildagent/work/[some folder]/build.cake:line 150
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass29_0.<Does>b__0(ICakeContext context) in C:projectscakesrcCake.CoreCakeTaskBuilder.Execution.cs:line 26
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass32_0.<Does>b__0(ICakeContext x) in C:projectscakesrcCake.CoreCakeTaskBuilder.Execution.cs:line 83
at Cake.Core.CakeTask.Execute(ICakeContext context) in C:projectscakesrcCake.CoreCakeTask.cs:line 125
at Cake.Core.DefaultExecutionStrategy.ExecuteAsync(CakeTask task, ICakeContext context) in C:projectscakesrcCake.CoreDefaultExecutionStrategy.cs:line 87
at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report) in C:projectscakesrcCake.CoreCakeEngine.cs:line 336
at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report) in C:projectscakesrcCake.CoreCakeEngine.cs:line 361
at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report) in C:projectscakesrcCake.CoreCakeEngine.cs:line 369
at Cake.Core.CakeEngine.RunTask(ICakeContext context, IExecutionStrategy strategy, CakeTask task, String target, Stopwatch stopWatch, CakeReport report) in C:projectscakesrcCake.CoreCakeEngine.cs:line 284
at Cake.Core.CakeEngine.RunTargetAsync(ICakeContext context, IExecutionStrategy strategy, ExecutionSettings settings) in C:projectscakesrcCake.CoreCakeEngine.cs:line 247
at Cake.Scripting.BuildScriptHost.RunTargetAsync(String target) in C:projectscakesrcCakeScriptingBuildScriptHost.cs:line 47
at Cake.Core.Scripting.ScriptHost.RunTarget(String target) in C:projectscakesrcCake.CoreScriptingScriptHost.cs:line 191
at Submission#0.<<Initialize>>d__0.MoveNext() in /opt/buildagent/work/[some folder]/build.cake:line 346
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Scripting.Script`1.RunSubmissionsAsync(ScriptExecutionState executionState, ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script) in C:projectscakesrcCakeScriptingRoslynRoslynScriptSession.cs:line 136
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments) in C:projectscakesrcCake.CoreScriptingScriptRunner.cs:line 219
at Cake.Commands.BuildCommand.Execute(CakeOptions options) in C:projectscakesrcCakeCommandsBuildCommand.cs:line 41
at Cake.CakeApplication.Run(CakeOptions options) in C:projectscakesrcCakeCakeApplication.cs:line 45
at Cake.Program.Main() in C:projectscakesrcCakeProgram.cs:line 80
Process exited with code 1

我也尝试了使用dotnet报告生成器globaltool,遇到了同样的错误。我还为ReportGenerator指定了ToolPath,以便使用.dll而不是.exe来运行ReportGenerator和dotnet ReportGenerator全局工具,但仍然没有成功。

请在下面找到我的蛋糕脚本的一部分:

#tool nuget:?package=ReportGenerator
#addin nuget:?package=Cake.Coverlet
// define variables
...
Task("Test")
.Does(() =>
{
var resultsFolder = Directory(@".coverage");
if (testProjectFiles != null)
{
var settings = new DotNetCoreTestSettings
{
Configuration = "Release"
};
foreach (var projectFile in testProjectFiles)
{
var coverletSettings = new CoverletSettings {
CollectCoverage = true,
CoverletOutputFormat = CoverletOutputFormat.opencover,
CoverletOutputDirectory = resultsFolder,
CoverletOutputName = $"{projectFile.GetFilenameWithoutExtension()}.opencover.xml",
};
Information("Running tests in {0}", projectFile.GetFilenameWithoutExtension());
DotNetCoreTest(projectFile.ToString(), settings, coverletSettings);
}
}
else
{
Warning("No unit tests found in the solution!");
}

});
Task("GenerateCoverageReport")
.Does(() =>
{
// Generate test coverage report
var reportGeneratorSetting = new ReportGeneratorSettings{
Verbosity = ReportGeneratorVerbosity.Verbose
};

//  ---> failing on teamcity
ReportGenerator("./coverage/*.xml", "./coverage", reportGeneratorSetting);
});

对于在teamcity上运行ReportGenerator,我缺少什么吗?请告知。

尝试使用dotnet工具包:

#module nuget:?package=Cake.DotNetTool.Module&version=0.4.0
#tool dotnet:?package=dotnet-reportgenerator-globaltool&version=4.6.7

然后调用Cake两次,首先引导模块:

dotnet cake --bootstrap --verbosity=verbose && dotnet cake --verbosity=verbose

相关内容

  • 没有找到相关文章

最新更新