Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.How many times have you created a console application to run specific tasks in .NET? These tasks could be processing a file, making some HTTP call to an external service or even helping in your build process. Ultimately ending up with a collection of different tasks which often have dependencies on each other. I just discovered a project called Bullseye by Adam Ralph which really feels like a simple task runner. But better yet, is just a library you add to your own console application and not its own process itself.
Bullseye is a .NET package for describing and running targets and their dependencies. Bullseye can be used to write targets that do anything. It is not coupled to building .NET projects. Platform support: .NET Standard 1.3 and upwards.
ExamplesThe simplest example which is described on the Bullseye readme is similar to as follows: There’s really only two components needed. Define your target(s) using the
Target()methods and then specify which targets to run via
RunTargets()If you do not specify a target to run then the “default” target is used. If you simply run
dotnet runwill produce the output: This would have been the equivalent of running
dotnet run default
DependenciesHere’s a simple example of having one target depend on another. In one target I’m hitting a service to get the exchange rate from CAD to USD. In another, I want to save that rate to a file. When run with
dotnet run saveexchangerateNow if I just want to get the rate but not save it, I could just run
dotnet run getexchangerate