adamralph / bau

The C# task runner
MIT License
152 stars 17 forks source link

ForAll: configure all tasks of particular type #222

Open eatdrinksleepcode opened 9 years ago

eatdrinksleepcode commented 9 years ago

It would be useful to have a method ("ForAll" is the proposed name, but there are a number of other possibilities) that can be used to configure all tasks of a particular type. For example, in the current baufile.csx, there are two instances of the MSBuild task that have a lot of duplicate configuration. Some of that duplication could be reduced by having some reasonable defaults on the MSBuild task (bau-build/bau-msbuild#15), but not all of it; for example, the solution file could not be defaulted, and we want to be able to set the configuration via a script property (#212). Those properties could potentially be set by calling a common method in the script, however that doesn't fit very well into the fluent syntax tha Bau uses (not to mention that ScriptCS seems to have a number of issues with embedded methods).

Proposed usage:

bau.ForAll<MSBuild>(msb => 
{
   msb.Solution = solution;
   msb.Properties = new { Configuration = "Release" };
};

This will be especially useful if we start using plugins that create tasks for us (as in #220).