Skip to content

Dependencies

Roman edited this page Aug 18, 2022 · 5 revisions

Tasks can have other tasks as dependencies. So if a dependency is defined, this dependency is run before the actual task. gotaskr makes sure that each task is only run once, even if it is defined in multiple other tasks.

A simple example would be Build -> Test -> Deploy

To define this in gotaskr, this would look like:

gotaskr.Task("Build", buildFunc)
gotaskr.Task("Test", testFunc).DependsOn("Build")
gotaskr.Task("Deploy", deployFunc).DependsOn("Test")

A task can also have multiple dependencies. In that case, they are executed in the order they are added as dependency.

The following example will run all tasks in that order.
Sidenote1: If each task has dependencies defined as above, then Deploy would be enough but I'm sure you get the point.
Sidenote2: goext.Noop is a special constant which represends a no-operation function that can be used for tasks without own logic.

gotaskr.Task("Full-Build", goext.Noop).DependsOn("Build", "Test", "Deploy")
Clone this wiki locally