-
-
Notifications
You must be signed in to change notification settings - Fork 731
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
Call multiple tasks from CLI and pass them to RunTarget #2470
Comments
I am also interested in this feature. We have modified build.cake to call RunTarget(target) within a
Command for example above: This issue seems to be trying to solve a similar problem, but with a different approach. |
Coming from MSBuild I would appreciate this feature, too. |
I'd like to have a go at this one @augustoproiete - please can you assign it to me? |
I have actually implemented this logic on a local branch to understand how it might work, see: https://github.com/FrankRay78/cake/tree/2470 The following build file with multiple targets now executes correctly:
What I am not sure is whether extending the current PS. I haven't implemented any unit tests for this yet on my local branch, but would do so prior to submitting a PR. |
I would expect this to not rely on string splitting but on the fact that Cake allows specifying the same argument multiple times, i.e. dotnet cake runtargets.cake --target=A --target=B --target=C and a cake script could look something like this var targets = Arguments<string>("target", "A");
Task("A");
Task("B");
Task("C");
RunTargets(targets); a way to simulate this now would be to add a meta task in a Cake script i.e. CakeReport RunTargets(ICollection<string> targets)
=> RunTarget(GetOrAddTargetsTask(targets).Name);
Task<CakeReport> RunTargetsAsync(ICollection<string> targets)
=> RunTargetAsync(GetOrAddTargetsTask(targets).Name);
private ICakeTaskInfo GetOrAddTargetsTask(ICollection<string> targets)
{
var targetsTaskName = string.Join(',', targets);
var targetsTask = Tasks.FirstOrDefault(
task => task.Name == targetsTaskName
);
if (targetsTask == null)
{
var task = Task(targetsTaskName);
foreach(var target in targets)
{
task.IsDependentOn(target);
}
targetsTask = task.Task;
}
return targetsTask;
} as PoC gist here: https://gist.github.com/devlead/84b21afe5688e638a86f85b940ae57be For that i.e. dotnet cake runtargets.cake --target=A will result in
and dotnet cake runtargets.cake --target=A --target=B will result in
and dotnet cake runtargets.cake --target=A --target=B --target=C will result in
|
Thanks @devlead, I'll put what you suggest into a PR for review... |
I have now raised a PR for this issue, see: #4054 |
Fixed by #4054 |
🎉 This issue has been resolved in version v3.0.0 🎉 The release is available on: Your GitReleaseManager bot 📦🚀 |
I used a lot of Gradle in the past. One of the most features I miss in Cake, is to run multiple tasks from CLI. In Gradle I could simple run
.\gradlew clean build
. In Cake I’m forced to useIsDependentOn
, which does not make sense in every use case (I don’t want to run clean on every build).It bothers me especial on my build environment (CI). It would be a lot easier to call multiple tasks in one stage. I think this would be a great feature and make Cake much better.
RunTarget
.IsDependentOn
tasks.The text was updated successfully, but these errors were encountered: