Reading Issues
The Cake.Issues
addin can be used to aggregate issues from different sources. This can for example be useful to break builds based on the reported issues.
List of all aliases for reading issues
See all available Aliases for reading issues
To read issues you need to import at least one issue provider. In the following example the issue providers for reading warnings from MsBuild log files and from JetBrains InspectCode are imported:
Example for other tools
For examples for issue providers for reading issues form other tools see Issue Provider Examples.
#addin nuget:?package=Cake.Issues&version=5.5.0
#addin nuget:?package=Cake.Issues.MsBuild&version=5.5.0
#addin nuget:?package=Cake.Issues.InspectCode&version=5.5.0
Note
In addition to the issue providers the Cake.Issues
core addin needs to be added.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.Frosting" Version="5.0.0" />
<PackageReference Include="Cake.Frosting.Issues.MsBuild" Version="5.5.0" />
<PackageReference Include="Cake.Frosting.Issues.InspectCode" Version="5.5.0" />
</ItemGroup>
</Project>
Afterwards you can define a task where you call the core addin with the desired issue providers. The following example reads warnings and errors reported by MsBuild from a binary log and issues reported by JetBrains InspectCode:
Task("Read-Issues").Does(() =>
{
var repoRootFolder = new DirectoryPath(@"C:\repo");
var issues = ReadIssues(
new List<IIssueProvider>
{
MsBuildIssuesFromFilePath(
@"C:\build\msbuild.log",
MsBuildBinaryLogFileFormat),
InspectCodeIssuesFromFilePath(
@"C:\build\inspectcode.log")
},
repoRootFolder);
Information("{0} issues are found.", issues.Count());
});
using Cake.Common.Diagnostics;
using Cake.Core.IO;
using Cake.Frosting;
public static class Program
{
public static int Main(string[] args)
{
return new CakeHost()
.Run(args);
}
}
[TaskName("Read-Issues")]
public sealed class ReadIssuesTask : FrostingTask<FrostingContext>
{
public override void Run(FrostingContext context)
{
var repoRootFolder = new DirectoryPath(@"C:\repo");
var issues = context.ReadIssues(
new List<IIssueProvider>
{
context.MsBuildIssuesFromFilePath(
@"C:\build\msbuild.log",
context.MsBuildBinaryLogFileFormat()),
context.InspectCodeIssuesFromFilePath(
@"C:\build\inspectcode.log")
},
repoRootFolder);
context.Information("{0} issues are found.", issues.Count());
}
}