Replies: 1 comment 3 replies
-
With 1.0 you could do something like this utilizing Arguments(string) alias and DoesForEach. targetframework.cakepublic record BuildData(ICollection<string> targetFrameworks);
Setup(
context => {
var targetFrameworks = context.Arguments<string>("framework");
return new BuildData(targetFrameworks);
}
);
Task("Test")
.DoesForEach<BuildData, string>(
(data, context) => data.targetFrameworks,
(data, targetFramework, context) => context.Information("Framework: {0}", targetFramework)
);
RunTarget("Test"); no args specifieddotnet cake targetframework.cake ----------------------------------------
Setup
----------------------------------------
- Error: One or more errors occurred. (Argument 'framework' was not set.)
- Argument 'framework' was not set. If you don't want it to throw on missing framework change to Arguments(string name, T default) i.e. var targetFrameworks = context.Arguments<string>("framework", "net5.0"); framework="net5.0"dotnet cake targetframework.cake --framework="net5.0"
framework="netcoreapp3.1"dotnet cake targetframework.cake --framework="netcoreapp3.1"
framework="net5.0" and framework="netcoreapp3.1"dotnet cake targetframework.cake --framework="net5.0" --framework="netcoreapp3.1"
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have the same task that needs to be run using two values of the same parameter.
It would be cool if I could define a parameter for the task, something like
Not sure how the
RunTest
task could be defined. Probably an overload of theDoes
method?Or maybe there is another way to achieve the same but I am not aware of it and I couldn't find it by simply searching through the documentation.
Beta Was this translation helpful? Give feedback.
All reactions