Examples

To analyze Git repositories you need to import the Git repository issue provider:

build.cake
#addin nuget:?package=Cake.Issues&version=5.2.0
#addin nuget:?package=Cake.Issues.GitRepository&version=5.2.0

Note

In addition to the Git repository issue provider the Cake.Issues core addin needs 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.GitRepository" Version="5.2.0" />
  </ItemGroup>
</Project>

The following example prints the number of binary files which are not tracked by Git Large File Storage in a repository.

Warning

Checking binary files requires Git and Git Large File Storage available on the local machine.

build.cake
Task("Analyze-Repo")
.Does(() =>
{
    // Read issues.
    var repoRootPath = MakeAbsolute(Directory("./"));
    var settings =
        new GitRepositoryIssuesSettings
        {
            CheckBinaryFilesTrackedByLfs = true
        };    

    var issues =
        ReadIssues(
            GitRepositoryIssues(settings),
            repoRootPath);    

    Information("{0} issues are found.", issues.Count());
});
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("Analyze-Repo")]
public sealed class AnalyzeRepoTask : FrostingTask<FrostingContext>
{
    public override void Run(FrostingContext context)
    {
        // Read issues.
        var repoRootPath = context.MakeAbsolute(context.Directory("./"));
        var settings =
            new GitRepositoryIssuesSettings
            {
                CheckBinaryFilesTrackedByLfs = true
            };    

        var issues =
            context.ReadIssues(
                context.GitRepositoryIssues(settings),
                repoRootPath);    

        context.Information("{0} issues are found.", issues.Count());
    }
}