Skip to content

SetupContext.TasksToExecute only lists tasks related to first target when calling RunTargets #4066

Description

@wazzamatazz

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake .NET Tool

Cake version

3.0.0

Operating system

Windows

Operating system architecture

64-Bit

CI Server

No response

What are you seeing?

When running multiple targets via the RunTargets method in dotnet cake v3.0.0, the SetupContext.TasksToExecute property passed to the script's Setup delegate only lists the tasks that will be run for the first target specified, rather than the tasks to run for all specified targets.

What is expected?

I would expect the SetupContext.TasksToExecute property to contain all tasks that will be run across all specified targets rather than just the first target.

Steps to Reproduce

Setup(context => {
    Console.WriteLine($"Tasks to run: {string.Join(", ", context.TasksToExecute.Select(x => x.Name))}");
});

Task("A").Does(() => {
    Console.WriteLine("Running A");
});

Task("B").Does(() => {
    Console.WriteLine("Running B");
});

RunTargets(new [] { "A", "B" });

Resulting output when running dotnet cake is:

----------------------------------------
Setup
----------------------------------------
Tasks to run: A

========================================
A
========================================
Running A

========================================
B
========================================
Running B

Output log

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions