cake-build / resources

Contains different kind of resources such as bootstrappers and configuration files.
MIT License
55 stars 78 forks source link

Cake bootstrapper should honor cake.config tools path (build.ps1, build.sh) #84

Closed augustoproiete closed 4 years ago

augustoproiete commented 4 years ago

What You Are Seeing?

build.ps1 and build.sh do not honor the Tools path defined in cake.config. The path for tools, add-ins, modules, etc. is hard-coded in the boostrapper.

What is Expected?

Before downloading Cake, build.ps1 and build.sh should read the tools path defined in cake.config and use that path to store the Cake tool before downloading.

What version of Cake are you using?

0.38.2

How Did You Get This To Happen? (Steps to Reproduce)

; This is the default configuration file for Cake.
; This file was downloaded from https://github.com/cake-build/resources

[Nuget]
Source=https://api.nuget.org/v3/index.json
UseInProcessClient=true
LoadDependencies=false

[Paths]
-Tools=./tools
+Tools=./build/tools
-Addins=./tools/Addins
+Addins=./build/tools/Addins
-Modules=./tools/Modules
+Modules=./build/tools/Modules

[Settings]
SkipVerification=false

image

flcdrg commented 4 years ago

FWIW I provided a solution to this in https://github.com/cake-build/resources/pull/17 but there was little enthusiasm for adding such support.

I've just updated my branch (rebased against master) but won't bother creating a new pull request unless there's renewed interest.

https://github.com/flcdrg/cake-resources/tree/UseConfig-15

pascalberger commented 4 years ago

What is the exact use case to change the folders?

As @flcdrg mentioned we're hesitant to add the complexity required to parse the cake.config file to the bootstrapper. These bootstrappers are intended as a starting point for what can be done. It is the developer's discretion to extend the bootstrapper to solve specific requirements like parsing config file.

A much simpler approach could be passing paths as set in the bootstrapper to Cake as done in https://github.com/cake-build/resources/pull/88. Would this also solve the use case?

augustoproiete commented 4 years ago

@flcdrg That looks good to me, though I personally do not rely on these bootstrappers anymore since the dotnet cake became mainstream so no strong desire on my side to have this fixed at this point.

@pascalberger My use case is that I have projects where the ./tools folder is already being used for other things and can't be written to.

Setting the paths in environment variables seem like it could be a viable workaround - it's just not as clean as parsing the cake.config from the point of view of the end-user... As one would have to set the paths in three files (build.sh, build.ps1, cake.config) instead of one (cake.config) and ensure they're always in sync. If we remove the paths from the cake.config we assume everyone in the team will always use the bootstrapper and that doesn't seem like a good approach to me.

That said, the dotnet cake tool honors the paths in the cake.config file and the boostrapping now is a one-liner dotnet tool restore && dotnet cake so I don't think it's worth spending more time on this.

flcdrg commented 4 years ago

Yep, that was my use case too - had a legacy solution that was already using the tools directory.

I'm also switching to dotnet-cake for new projects, but then because they're new I don't try and use the tools directory for anything else either!

gep13 commented 4 years ago

@flcdrg While we might not bring this work into these bootstrappers, I think I might still use your code (so don't delete it just yet 😄 ) in order to parse the cake.config to allow specifying the version of .Net Core to use in a set of bootstrappers for running Cake.Tool.

flcdrg commented 4 years ago

@gep13 don't worry, I still use it myself so I plan to keep the branch around, even if it isn't merged in officially :-)

pascalberger commented 4 years ago

We can add a blog post to the cakebuild.net website how to update bootstrapper to parse cake.config file. This would give it some visibility, without adding the complexity to the default bootstrapper.

@flcdrg would you be interested in this?

flcdrg commented 4 years ago

@pascalberger sure.. what's the best way to get you the content?

pascalberger commented 4 years ago

@flcdrg You can create a PR for the blog post by adding a markdown file to https://github.com/cake-build/website/tree/master/input/blog

pascalberger commented 3 years ago

Blog post is now available here: https://cakebuild.net/blog/2020/12/config-bootstrap