Skip to content

adamralph/bullseye

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Bullseye

Bullseye

NuGet version

CI CodeQL analysis InferSharp Lint Spell check

Bullseye is a .NET library that runs a target dependency graph.

Bullseye is typically used as a build tool for .NET projects, and is usually used together with SimpleExec, but Bullseye targets can do anything. They are not restricted to building .NET projects. Bullseye is useful for any program which performs a series of operations.

Platform support: .NET 8.0 and later.

Quick start

  • Next to an existing .NET solution (.sln/.slnx file), add a .NET console app named Targets β€” dotnet new console --name Targets1
  • Change to the new directory β€” cd Targets
  • Add a reference to Bullseye β€” dotnet add package Bullseye
  • Add a reference to SimpleExec β€” dotnet add package SimpleExec
  • Replace the contents of Targets/Program.cs with:
    using static Bullseye.Targets;
    using static SimpleExec.Command;
    
    Target("build", () => RunAsync("dotnet", "build --configuration Release"));
    Target("test", dependsOn: ["build"], () => RunAsync("dotnet", "test --configuration Release --no-build"));
    Target("default", dependsOn: ["test"]);
    
    await RunTargetsAndExitAsync(args, ex => ex is SimpleExec.ExitCodeException);
  • Change to the solution directory β€” cd ..
  • Run the Targets project β€” dotnet run --project Targets.

VoilΓ ! You just wrote and ran your first Bullseye build program.

For help, run dotnet run --project Targets -- --help.

1. You could use a file-based C# program instead, but, at the time of writing, IDE support for file-based C# programs is not complete, so if you want full debugging, Intellisense, etc., it's a better to use a .NET console app.

Sample wrapper scripts

build (Linux and macOS)

#!/usr/bin/env bash
set -euo pipefail
dotnet run --project Targets -- "$@"

build.cmd (Windows)

@echo Off
dotnet run --project Targets -- %*

Enumerable inputs

For example, you may want to run your test projects one by one, so that the timing of each one and which one, if any, failed, is displayed in the Bullseye build summary:

Target(
    "test",
    dependsOn: ["build"],
    forEach: ["./FooTests.Acceptance", "./FooTests.Performance"],
    project => RunAsync($"dotnet", $"test {project} --configuration Release --no-build"));
dotnet run --project Targets -- test

Command-line arguments

Generally, all the command-line arguments passed to Program.cs should be passed along to Bullseye, as shown in the quick start above (RunTargetsAndExitAsync(args);). This is because Bullseye effectively provides a command-line interface (CLI), with options for displaying a list of targets, performing dry runs, suppressing colour, and more. For full details of the command-line options, run your targets project supplying the --help (-h/-?) option:

dotnet run --project Targets -- --help
./build --help
./build.cmd --help

You can also handle custom arguments in Program.cs, but you should ensure that only valid arguments are passed along to Bullseye and that the help text contains both your custom arguments and the arguments supported by Bullseye. A good way to do this is to use a command-line parsing package to define your custom arguments, and to provide translation between the package and Bullseye. For example, see the test projects for:

Non-static API

For most cases, the static API described above is sufficient. For more complex scenarios where a number of target collections are required, the non-static API may be used.

var targets1 = new Targets();
targets1.Add("foo", () => Console.Out.WriteLine("foo1"));

var targets2 = new Targets();
targets2.Add("foo", () => Console.Out.WriteLine("foo2"));

await targets1.RunWithoutExitingAsync(args);
await targets2.RunWithoutExitingAsync(args);

NO_COLOR

Bullseye supports NO_COLOR.

Who's using Bullseye?

To name a few:

Feel free to send a pull request to add your repository or organisation to this list!


Target by Franck Juncker from the Noun Project.

About

🎯 A .NET library for running a target dependency graph.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Contributors 13