cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.87k stars 727 forks source link

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

Open wazzamatazz opened 1 year ago

wazzamatazz commented 1 year ago

Prerequisites

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