cake-build / cake

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

Request for Task.Tool("nuget:?package=etc") #1269

Open jnm2 opened 8 years ago

jnm2 commented 8 years ago

Right now I have to choose between #tool nuget:?package=SomePackageName which runs for all tasks, even Clean, and NuGetInstall("SomePackageName", new NuGetInstallSettings { OutputDirectory = buildToolsDir, ExcludeVersion = true }); inside the Does block which only runs when needed.

What if there was a Task builder method so we could specify .Tool("nuget:?package=SomePackageName") right on the Task declaration? That feels much cleaner to me, especially on a build server than may not even need to download the tool for the target it's running.

For efficiency, the tool reference could probably still be collected and updated in the same batch as the #tool directives; it wouldn't even be a separate call like NuGetInstall currently is.

I'm willing to PR if you think this is a good addition.

devlead commented 8 years ago

@jnm2 Feels like something that could be added as an focused PoC extension method, but would need to give some thought on implications of this. @cake-build/team thoughts?

Roemer commented 7 years ago

I'd love to see this feature implemented. As you said, that can be quite a time-saver in a CI.

gep13 commented 7 years ago

@Roemer while this isn't baked in yet, it is possible to implement on your own.

Have a look here:

https://github.com/cake-contrib/Cake.Recipe/blob/develop/Cake.Recipe/Content/tools.cake#L21

with an example of it's use here:

https://github.com/cake-contrib/Cake.Recipe/blob/d1a810117482f5f88d49a104175539394d9c4980/Cake.Recipe/Content/analyzing.cake#L6

Hope that helps!