Examples

To report issues to the console the Console report format needs to be imported. For this example the MsBuild issue provider is additionally used for reading issues:

build.cake
#addin nuget:?package=Cake.Issues&version=5.2.0
#addin nuget:?package=Cake.Issues.MsBuild&version=5.2.0
#addin nuget:?package=Cake.Issues.Reporting&version=5.2.0
#addin nuget:?package=Cake.Issues.Reporting.Console&version=5.2.0

Note

In addition to the Console report format the Cake.Issues and Cake.Issues.Reporting core addins need to be added.

Build.csproj
<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.2.0" />
    <PackageReference Include="Cake.Frosting.Issues.Reporting.Console" Version="5.2.0" />
  </ItemGroup>
</Project>

The following example will print issues logged as warnings by MsBuild to the console.

build.cake
Task("Create-IssueReport").Does(() =>
{
    var repoRootPath = MakeAbsolute(Directory("./"));

    // Build MySolution.sln solution in the repository root folder and write a binary log.
    FilePath msBuildLogFile = @"c:\build\msbuild.log";
    var msBuildSettings =
        new DotNetMSBuildSettings().WithLogger(
            "BinaryLogger," + Context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll"),
            "",
            msBuildLogFile.FullPath);
    DotNetBuild(
        repoRootPath.CombineWithFilePath("MySolution.sln").FullPath,
        new DotNetBuildSettings{MSBuildSettings = msBuildSettings});

    // Write issues to console.
    CreateIssueReport(
        MsBuildIssuesFromFilePath(
            msBuildLogFile,
            MsBuildBinaryLogFileFormat),
        ConsoleIssueReportFormat(
            new ConsoleIssueReportFormatSettings
            {
                GroupByRule = true,
                ShowProviderSummary = true,
                ShowPrioritySummary = true
            }),
        repoRootPath,
        string.Empty);
});
Program.cs
using Cake.Common.IO;
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.Build;
using Cake.Common.Tools.DotNet.MSBuild;
using Cake.Core.IO;
using Cake.Frosting;

public static class Program
{
    public static int Main(string[] args)
    {
        return new CakeHost()
            .Run(args);
    }
}

[TaskName("Create-IssueReport")]
public sealed class CreateIssueReportTask : FrostingTask<FrostingContext>
{
    public override void Run(FrostingContext context)
    {
        var repoRootPath = context.MakeAbsolute(context.Directory("./"));

        // Build MySolution.sln solution in the repository root folder and write a binary log.
        FilePath msBuildLogFile = @"c:\build\msbuild.log";
        var msBuildSettings =
            new DotNetMSBuildSettings().WithLogger(
                "BinaryLogger," + context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll"),
                "",
                msBuildLogFile.FullPath);
        context.DotNetBuild(
            repoRootPath.CombineWithFilePath("MySolution.sln").FullPath,
            new DotNetBuildSettings{MSBuildSettings = msBuildSettings});

        // Write issues to console.
        context.CreateIssueReport(
            context.MsBuildIssuesFromFilePath(
                msBuildLogFile,
                context.MsBuildBinaryLogFileFormat()),
            context.ConsoleIssueReportFormat(
                new ConsoleIssueReportFormatSettings
                {
                    GroupByRule = true,
                    ShowProviderSummary = true,
                    ShowPrioritySummary = true
                }),
            repoRootPath,
            string.Empty);
    }
}