FlubuCore

Why FlubuCore?
  • Native access to the whole .NET ecosystem and full IDE support inside of your scripts.
  • With Flubu you can execute your script anywhere, it doesn't need to be in a project. This is important for deployment scripts or if you want to write some other scripts that are not releated to build scirpts or deploy scripts
  • Flubu allows multiple tasks in target.
  • Easy access to tasks through fluent interface Context.AddTask() or Context.Tasks()
  • Each Flubu built in task derives from base class task meaning each built in task have retry, OnError, Finally, When, Interactive and some others mechanisms
  • Pass command line arguments, settings from json configuration file or environment variables to your Properties in script.
  • Allows you to reuse set of tasks. See Sample
  • Flubu supports parallel / async execution of target's, target dependencies and tasks
  • to each task that execute external program or command you can add custom arguments with .WithArguments() method or even decide not to use fluent interface (good example: https://github.com/azabluda/InfoCarrier.Core/blob/develop/BuildScript/BuildScript.cs)
  • Alternative target definitions with attributes
  • Flubu web api allows you to execute scripts remotely (usefull for deployments but not limited to)
  • Override existing options or add additional options to tasks through console. https://flubucore.dotnetcore.xyz/override-add-options/
  • Flubu have really nice interactive mode https://flubucore.dotnetcore.xyz/build-script-runner-interactive/
  • Flubu Supports .net 461+ and .net core 1.0
Should I call Execute method when executing Flubu built in task?

If you are adding tasks to target through AddTask method, Flubu calls Execute method when executing that target so in this scenario you should not call Execute on the task.

1
2
context.CreateTarget("Build")
       .AddCoreTask(x => x.build());

In the sample above, a BuildTask is added to the target. When target is executed Flubu executes all tasks that were added to target by calling task's Execute method. In this case it executes BuildTask.

1
2
3
4
5
6
7
8
context.CreateTarget("LoginEcr")
    .Do(c =>
    {
        c.Tasks()
         .RunProgram("aws") 
         .WithArguments("ecr", "get-login", "--region", "eu-central-1", "--no-include-email"))
         .Execute(context);
    }

In this sample, Do method actually adds a DoTask to the target. When target is executed Flubu executes DoTask. DoTask in above example invokes an anonymous method which was assigned to the Action delegate (first parameter in Do method).
Flubu can not execute by itself tasks in the anonymous method you have to call Execute() method manually.

Can I get output of the program, process or command that I am executing with Flubu?

Yes you can with CaptureOutput method in RunProgramTask

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
public class MyScript : DefaultBuildScript
{
    protected override void ConfigureTargets(ITaskContext context)
    {
        context.CreateTarget("Example")
            .Do(RunProgramOrCommandExample);
    }

    public void RunProgramOrCommandExample(ITaskContext context)
    {
        var task = context.Tasks().RunProgramTask("EnterPathToProgramOrCommand")
            .WithArguments("Add arguments if needed")
            .CaptureOutput();

        task.Execute(context);

        var output = task.GetOutput();
    }
}
Can I access Properties or Flubu BuildProperties in ConfigureTargets method?

In most cases you can as long as they are not set in a Do method or in a task.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public BuildVersion BuildVersion { get; set; } = null;

public int SimpleSample {get; set; } = 0;

protected override void ConfigureTargets(ITaskContext context)
{
   var fetchBuildVersion context.CreateTarget("fetch.buildVersion").Do(FetchBuildVersion);

    context.CreateTarget("Build")
        .DependsOn(fetchBuildVersion)
        .AddCoreTask(x => x.Build()
            .Version(BuildVersion.BuildVersionWithQuality())); /// BuildVersion is null here.

    context.LogInfo($"sample value: '{SimpleSample}'"); /// logs 0 and not 5. Explained below why is it so.
}

private void FetchBuildVersion(ITaskContext context)
{
    BuildVersion = context.Tasks().FetchBuildVersionFromFileTask()
        .ProjectVersionFileName("project_version.txt")
        .Execute(context);

    SimpleSample = 5;
}

In sample above you could think that when property SimpleSample is accessed in ConfigureTargets it would not be 0 but it is, becuase ConfigureTargets method is always executed before all targets that are executed with Flubu.

ConfigureTargets is also executed before all target dependecnies and tasks that were added to target