Report Issues To Pull Requests

To use report issues to pull requests you need to import the corresponding pull request system addin. In the following example the issue provider for reading warnings from MsBuild log files and support for Azure DevOps pull requests is imported:

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

Note

In addition to the pull request system the Cake.Issues and Cake.Issues.PullRequests 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.PullRequests.AzureDevOps" Version="5.2.0" />
  </ItemGroup>
</Project>

Afterwards you can define a task where you call the core addin with the desired issue provider and pull request system:

build.cake
    Task("ReportIssuesToPullRequest").Does(() =>
    {
        var repoRootFolder = new DirectoryPath(@"C:\repo");
        ReportIssuesToPullRequest(
            MsBuildIssuesFromFilePath(
                @"C:\build\msbuild.log",
                MsBuildBinaryLogFileFormat),
            AzureDevOpsPullRequests(),
            repoRootFolder);
    });
Program.cs
using Cake.Core.IO;
using Cake.Frosting;

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

[TaskName("ReportIssuesToPullRequest")]
public sealed class ReportIssuesToPullRequestTask : FrostingTask<FrostingContext>
{
    public override void Run(FrostingContext context)
    {
        var repoRootFolder = new DirectoryPath(@"C:\repo");
        context.ReportIssuesToPullRequest(
            context.MsBuildIssuesFromFilePath(
                @"C:\build\msbuild.log",
                context.MsBuildBinaryLogFileFormat()),
            context.AzureDevOpsPullRequests(),
            repoRootFolder);
    }
}