Working with ReportGenerator in Cake #599
-
I am having issues with ReportGenerator in a Cake Build Script and I'm not sure I have configured it correctly I am running the Cake Script on a Linux Machine const string TEST_COVERAGE_OUTPUT_DIR = "coverage";
Task("Test")
.IsDependentOn("Build")
.Does(() => {
var testSettings = new DotNetTestSettings {
Configuration = configuration,
NoBuild = true,
};
var projects = GetFiles("./test/**/*.csproj");
foreach(var project in projects )
{
var coverageOutput = Directory(TEST_COVERAGE_OUTPUT_DIR);
var codeCoverageOutputName = $"{project.GetFilenameWithoutExtension()}.cobertura.xml";
var coverletSettings = new CoverletSettings {
CollectCoverage = true,
CoverletOutputFormat = CoverletOutputFormat.cobertura,
CoverletOutputDirectory = coverageOutput,
CoverletOutputName =codeCoverageOutputName,
ArgumentCustomization = args => args.Append($"--logger trx")
};
Information($"Running Tests : { project.ToString()}");
DotNetTest(project.ToString(), testSettings, coverletSettings );
}
});
Task("GenerateReport")
.IsDependentOn("Test")
.Does(() =>
{
var directory = Directory(TEST_COVERAGE_OUTPUT_DIR);
Information($"Directory Path : { directory.ToString()}");
var glob = new GlobPattern($"./{ directory}/*.cobertura.xml");
Information($"globpattern : { glob.ToString()}");
var outputDirectory = Directory("./reports");
var reportSettings = new ReportGeneratorSettings
{
ArgumentCustomization = args => args.Append($"-reportTypes:HtmlInline_AzurePipelines")
};
ReportGenerator(glob, outputDirectory, reportSettings);
}); When I execute script , the cobertura files are generated However, when attempting to generate the reports I get n error occurred when executing task 'GenerateReport'. When I installed the Report Generator locally and exexuted ~/tools/reportgenerator -reports:*-coverage.cobertura.xml -targetdir:report It generates the report as expected but it doesn't in the Cake Script Is there some addtional configuration I need to do in the Cake Script ? Which seemed to indicate I needed to register the tool locally. I assumed Cake took care of that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think I managed to resolve the issue myself I found this https://www.nuget.org/packages/dotnet-reportgenerator-globaltool I then added the following import to my cake script #tool dotnet:?package=dotnet-reportgenerator-globaltool&version=5.1.19 I then ran the script and it all worked! |
Beta Was this translation helpful? Give feedback.
I think I managed to resolve the issue myself
I found this https://www.nuget.org/packages/dotnet-reportgenerator-globaltool
I then added the following import to my cake script
I then ran the script and it all worked!