Skip to content

Instantly share code, notes, and snippets.

@devlead
Created November 25, 2020 14:19
Show Gist options
  • Save devlead/41d97860ab2ee8fb2076fb3bc9dccc12 to your computer and use it in GitHub Desktop.
Save devlead/41d97860ab2ee8fb2076fb3bc9dccc12 to your computer and use it in GitHub Desktop.
Example use task setup/teardown to modify build state
public class BuildData
{
public string TaskName { get; set; }
}
Setup(context => new BuildData());
TaskSetup<BuildData>(
(context, data) => data.TaskName = context.Task.Name
);
TaskTeardown<BuildData>(
(context, data) => data.TaskName = null
);
Task("My Task")
.Does<BuildData>(
(context, data)
=> context.Information("Executing {0}", data.TaskName)
);
RunTarget("My Task");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment