cake-build / cake

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

Use a `.cake` folder by default instead of a `tools` folder #3263

Open augustoproiete opened 3 years ago

augustoproiete commented 3 years ago

Tracking improvement originally from discussion https://github.com/cake-build/cake/discussions/2979 targeting Cake v2.0

As we all know, Cake uses a folder for downloading and extracting NuGet packages (and other things), and by default it uses a ./tools folder.

There a couple of (small) issues I've seen because of that:

  1. Adding Cake to existing projects (any language/platform) ./tools is a common enough name that some projects use for other purposes (even internal to the project) and when introducing Cake to existing projects that already define a ./tools folder, one needs to be careful to ensure Cake won't touch that folder and will use a different folder instead, which is not as straightforward as changing the cake.config as sometimes that means adapting bootstrappers that don't honor what's set in the cake.config.

  2. Adding Cake to new projects (.NET-specific) When starting a new project, it's common for devs to use the default VisualStudio.gitignore on GitHub. The good news is that this .gitignore already brings a couple of lines specific to Cake. The bad news is that they are commented out, because having a ./tools by default would be too broad of a rule.

If Cake started using a .cake folder (or similar), it would avoid the issues above as it's unlikely users would have a .cake folder for a different purpose other than using Cake, and it would be specific enough to be included in the VisualStudio.gitignore template.

joshuacookdev commented 3 years ago

Implementation question:

./.cake/tools/ or ./.cake/? I know the request says ./.cake/, but I feel like putting the tools under ./.cake/tools/ might be a better long-term option.

If no one has picked this up by the weekend, I'll likely play around with it - just wanted to bring that up for discussion before any work began on the issue. Never mind, I didn't realize you had self-assigned the issue.

augustoproiete commented 3 years ago

Hey @joshuacookdev,

TL;DR; I think ./.cake/tools/ is a good idea and probably where we'd want to get to, but let's do that as a separate issue to make it easier to review, test, & merge this one.


Long version:

At the moment, if you have (for example) a Cake script like the following:

#addin "nuget:?package=Cake.ExcelDnaPack&version=1.0.1"
#module "nuget:?package=Cake.BuildSystems.Module&version=3.0.3"
#tool "nuget:?package=7-Zip.CommandLine"
#load "nuget:?package=Cake.Recipe&version=2.2.1"

You'll end up with with a folder structure like this:

image

As you can see, Cake #addins and #modules get their own folder, but #tools and #recipes don't, and their packages are extracted to the root of the configured tools folder.

I think it would make sense to have #tools and #recipes in their own folders, but that might have a bigger impact and require a more thorough testing, and probably make this PR harder to review and merge.

I suggest we keep the scope of this one small, just renaming the default tools folder to .cake and we create two separate issues to be implemented after this one is merged: