Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task chains #4367

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

ruslanmogilevskiy
Copy link

@ruslanmogilevskiy ruslanmogilevskiy commented Oct 16, 2024

The discussion is started here.

Problem:
Managing build task dependencies in Cake Frosting can become challenging as projects grow, especially when maintaining and modifying task chains later. While existing solutions (IsDependentOn/IsDependeeOf attributes and Cake.Graph) help visualize dependencies, they don't provide a clear, maintainable way to manage the task execution chain.

Solution:
This PR introduces a Task Chain paradigm that allows developers to:

  • Define task execution order in a clear, sequential manner
  • Organize tasks into logical groups with support for nested grouping
  • Reference tasks by both type and name
  • Maintain compatibility with existing dependency systems

The task chain is enabled with a single line of the configuration code:

return new CakeHost()
    ...
	.UseChainedTaskConfigurator<AppTaskChainProvider>()
	.Run(args);

Example usage:

class AppTaskChainProvider : ITaskChainProvider
{
    public TaskChainItem GetChain()
    {
        return Chain
            .Task<Task1>()
            .Group("Do something", _ =>
            {
                 // Reference the task type.
                _.Task<Task2>()
                 // Reference the task by name ([TaskName("Task3: do something")]).
                 .Task("Task3: do something");
            })
        // Task chain inline groups example.
        // .Group("Do something else", _ =>
        // {
        //     _.Task<SomeTask>()
        //      .Group("Internal group", _ =>
        //         {
        //             _.Task<OtherTask>();
        //         })
        //      .Task("Task name");
        // })
            // The last task in the chain which the Default task will be dependent on to execute all the chain.
            .Task<FinalTask>();
    }
}

This approach significantly improves build script maintainability and readability, making it easier to modify task chains as projects evolve. The implementation requires minimal configuration and can be gradually adopted alongside existing task dependencies

@ruslanmogilevskiy
Copy link
Author

@microsoft-github-policy-service agree

@ruslanmogilevskiy
Copy link
Author

@devlead , I've completed the PR description.

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

Successfully merging this pull request may close these issues.

2 participants