Sharing state between Targets

52 Views Asked by At

Is it possible to share state between Targets in Nuke?

Lets say I wanted this scenerario.

class Build : NukeBuild {
    public static int Main () => Execute<Build>(x => x.Clean);

    Target Clean => _ => _
        .Executes(() =>
        {
            string stateToRestore = "I am needed in Restore Target"; 
        });

    Target Restore => _ => _
        .DependsOn(Clean)
        .Executes(() =>
        {
            Console.WriteLine(stateToRestore);
        });
}

I know it is possible to either create a property, field or some object holding the state in the scope of Build class. I am looking for an builtin solution in Nuke or a "cleaner" solution whatever that means.

0

There are 0 best solutions below