Creating Issues

The Cake.Issues addin can be used to create issues directly in the build script. This issues can for example be used to create reports.

To create issues you need to import the following core addin:

build.cake
#addin nuget:?package=Cake.Issues&version=5.2.0
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.Issues" Version="5.2.0" />
  </ItemGroup>
</Project>

In the following task a new warning for the myfile.txt file on line 42 is created:

build.cake
Task("Create-Issue").Does(() =>
{
    var issue =
        NewIssue(
            "Something went wrong",
            "MyCakeScript",
            "My Cake Script")
            .WithMessageInHtmlFormat("Something went <b>wrong</b>")
            .WithMessageInMarkdownFormat("Something went **wrong**")
            .InFile("myfile.txt", 42)
            .WithPriority(IssuePriority.Warning)
            .Create();

    Information("Issue created with message: {0}", issue.MessageText);
});
Program.cs
using Cake.Common.Diagnostics;
using Cake.Frosting;

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

[TaskName("Create-Issue")]
public sealed class CreateIssueTask : FrostingTask<FrostingContext>
{
    public override void Run(FrostingContext context)
    {
        var issue =
            context.NewIssue(
                "Something went wrong",
                "MyCakeScript",
                "My Cake Script")
                .WithMessageInHtmlFormat("Something went <b>wrong</b>")
                .WithMessageInMarkdownFormat("Something went **wrong**")
                .InFile("myfile.txt", 42)
                .WithPriority(IssuePriority.Warning)
                .Create();

        context.Information("Issue created with message: {0}", issue.MessageText);
    }
}