Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Frosting) Tool installer should respect configuration #2904

Closed
patriksvensson opened this issue Feb 22, 2017 · 20 comments · Fixed by #2946 or #3095
Closed

(Frosting) Tool installer should respect configuration #2904

patriksvensson opened this issue Feb 22, 2017 · 20 comments · Fixed by #2946 or #3095
Assignees
Milestone

Comments

@patriksvensson
Copy link
Member

patriksvensson commented Feb 22, 2017

Frosting should support configuration.

@gep13
Copy link
Member

gep13 commented Jul 1, 2020

@patriksvensson can you provide more information regarding what this issue was for? Thanks

@pascalberger pascalberger changed the title Tool installer should respect configuration (Frosting) Tool installer should respect configuration Oct 19, 2020
@pascalberger pascalberger transferred this issue from cake-archive/frosting Oct 19, 2020
dieterv pushed a commit to dieterv/cake that referenced this issue Nov 17, 2020
@dieterv
Copy link

dieterv commented Nov 17, 2020

@gep13 Frosting uses an internal ToolInstaller which does not respect the tools path configuration option.
Instead it is currently hardcoded to place tools into _environment.WorkingDirectory.Combine("tools").MakeAbsolute(_environment) which usually ends up being somthing like project-root/tools/.

Something like this might be a first step to solve this. I did notice that Cake.Core.Constants is not accessible though and have no idea what would be preferred, making the constants public or duplicating them in the Cake.Frosting project somewhere?

Note that this would also require the NuGetModule changes from the release/1.0.0 branch, commit daf0142 I think, to be actually useful. Without that, we're stuck creating our own NuGetModule in our Program.Configure using an emtpy CakeConfiguration object for now, as mentioned here.

@patriksvensson
Copy link
Member Author

@dieterv This has been fixed in #2946 which will be merged shortly.

@pascalberger pascalberger added this to the v1.0.0 milestone Nov 17, 2020
@pascalberger pascalberger linked a pull request Nov 17, 2020 that will close this issue
@devlead
Copy link
Member

devlead commented Dec 9, 2020

Fixed by #2946

@dieterv
Copy link

dieterv commented Dec 29, 2020

@patriksvensson upgraded to 1.0.0-rc0002 and it looks like Frosting does not yet respect the settings from the [Paths] section of my cake.config file. Digging a bit deeper and it looks like the internal ToolInstaller still uses a hardcoded _environment.WorkingDirectory.Combine("tools").MakeAbsolute(_environment); path, see
https://github.com/cake-build/cake/blob/main/src/Cake.Frosting/Internal/ToolInstaller.cs#L30

Additionally, it no longer seems to take the working directory change into account as configured on the CakeHost instance as was the case in rc0001.

        // Create and run the host.
        return new CakeHost()
            .UseWorkingDirectory("../..")
            .UseContext<Context>()
            .UseLifetime<Lifetime>()
            .Run(args);

@pascalberger
Copy link
Member

Additionally, it no longer seems to take the working directory change into account as configured on the CakeHost instance as was the case in rc0001.

@dieterv Do you have an example where working directory fails? I just tried with a following simple example with the build script in a build folder and the solution in a src folder and setting working directory: https://github.com/pascalberger/cake-frosting-example

dieterv pushed a commit to dieterv/cake-frosting-example that referenced this issue Jan 4, 2021
An example using Cake.Frosting 1.0.0-rc0002 which shows
the `ToolInstaller` still uses a hardcoded
`_environment.WorkingDirectory.Combine("tools").MakeAbsolute(_environment);`
path to install tools into.


Observe that CakeHost() was configured with a .UseWorkingDirectory("../..")
but surprisingly the tools end up being installed in `./build/source/tools`
instead of the expected `./tools` directory as was the case
in Cake.Frosting 1.0.0-rc0001.

Now, as far as the `ToolInstaller` is concerned, both are wrong.
The [Paths][Tools] setting from the cake.config file should be used instead.

See cake-build/cake#2904 (comment)
dieterv pushed a commit to dieterv/cake-frosting-example that referenced this issue Jan 4, 2021
An example using Cake.Frosting 1.0.0-rc0002 which shows
the `ToolInstaller` still uses a hardcoded
`_environment.WorkingDirectory.Combine("tools").MakeAbsolute(_environment);`
path to install tools into.


Observe that CakeHost() was configured with a .UseWorkingDirectory("../..")
but surprisingly the tools end up being installed in `./build/source/tools`
instead of the expected `./tools` directory as was the case
in Cake.Frosting 1.0.0-rc0001.

Now, as far as the `ToolInstaller` is concerned, both are wrong.
The [Paths][Tools] setting from the cake.config file should be used instead.

See cake-build/cake#2904 (comment)
dieterv pushed a commit to dieterv/cake-frosting-example that referenced this issue Jan 4, 2021
An example using Cake.Frosting 1.0.0-rc0002 which shows
the `ToolInstaller` still uses a hardcoded
`_environment.WorkingDirectory.Combine("tools").MakeAbsolute(_environment);`
path to install tools into.


Observe that CakeHost() was configured with a .UseWorkingDirectory("../..")
but surprisingly the tools end up being installed in `./build/source/tools`
instead of the expected `./tools` directory as was the case
in Cake.Frosting 1.0.0-rc0001.

Now, as far as the `ToolInstaller` is concerned, both are wrong in this case.
The [Paths][Tools] setting from the cake.config file has been specified and
should be used instead.

See cake-build/cake#2904 (comment)
@dieterv
Copy link

dieterv commented Jan 4, 2021

@dieterv Do you have an example where working directory fails? I just tried with a following simple example with the build script in a build folder and the solution in a src folder and setting working directory: https://github.com/pascalberger/cake-frosting-example

@pascalberger sure, I've modified your example to show that ToolInstaller does not use the working directory that was configured on CakeHost, see dieterv/cake-frosting-example@76e6518

Now, interesting as this is, the [Paths][Tools] setting from the cake.config file should be used instead, when available, which is not the case unfortunately.

devlead added a commit to devlead/cake that referenced this issue Jan 28, 2021
* Frosting utilize CakeConfigurationProvider, enables config
    * Frosting IServiceCollection.UseToolPath
    * cake.config file
    * environment variables
    * command line arguments
* Tools path should be resolved using configuration
* fixes cake-build#2904
devlead added a commit to devlead/cake that referenced this issue Jan 28, 2021
* Frosting utilize CakeConfigurationProvider, enables config
    * Frosting IServiceCollection.UseToolPath
    * cake.config file
    * environment variables
    * command line arguments
* Tools path should be resolved using configuration
* fixes cake-build#2904
@devlead
Copy link
Member

devlead commented Jan 28, 2021

I've submitted #3059 as a proposed fix which support both config via cake.config/environment variables/args and a UseToolPath method in frosting.

@devlead
Copy link
Member

devlead commented Jan 29, 2021

Sure, but keeps the problem that most of current settings don't make sense for Frosting:
* CAKE_NUGET_LOADDEPENDENCIES
* CAKE_PATHS_ADDINS
* CAKE_NUGET_USEINPROCESSCLIENT
* CAKE_PATHS_MODULES
* CAKE_NUGET_CONFIGFILE
* CAKE_NUGET_SOURCE

At least the CAKE_NUGET_* ones are used in Frosting though as it uses Cake.NuGet now.

@pascalberger
Copy link
Member

Sure, but keeps the problem that most of current settings don't make sense for Frosting:

  • CAKE_NUGET_LOADDEPENDENCIES
  • CAKE_PATHS_ADDINS
  • CAKE_NUGET_USEINPROCESSCLIENT
  • CAKE_PATHS_MODULES
  • CAKE_NUGET_CONFIGFILE
  • CAKE_NUGET_SOURCE

At least the CAKE_NUGET_* ones are used in Frosting though as it uses Cake.NuGet now.

But only for tools and not for addins and modules which are added through PackageReferences.

@dieterv
Copy link

dieterv commented Jan 29, 2021

@pascalberger wrote:

cake.config is currently not supported in Frosting. We updated documentation to mention this: https://cakebuild.net/docs/running-builds/configuration/set-configuration-values.

But 1.0.0-rc003 will add a SetToolPath method on the Cake host which can be used to set the tool path.

Fair enough, my projects where migrated from older build.cake files.
Guess I just assumed settings in the cake.config files would be used.
Thanks for updating the docs, that will surely help people migrating in the future!

Ah, yes, a SetToolPath method would be great and allow us to remove our config files altogether, thank you 🙏

@gep13
Copy link
Member

gep13 commented Jan 29, 2021

@dieterv said...
Fair enough, my projects where migrated from older build.cake files.
Guess I just assumed settings in the cake.config files would be used.

This is the really the scenario that I was thinking about when I said:

Frosting could just ignore them though, right? And only use the ones that it needs.

Folks that are moving from Cake Scripting to Frosting would expect that any existing configuration to be applied, where it makes sense. That is why I think going forward Frosting should recognise if there is a cake.config file, and take out what is useful and ignore the rest.

@devlead
Copy link
Member

devlead commented Jan 29, 2021

But only for tools and not for addins and modules which are added through PackageReferences.

I was just correcting the fact that they didn't make sense at all. There're code-paths that're used in release/1.0.0 branch.

So correct list configuration used by Forsting is:

  • SETTINGS_SHOWPROCESSCOMMANDLINE
  • SETTINGS_NOMONOCOERSION <-- needs to be documented
  • PATHS_TOOLS
  • NUGET_LOADDEPENDENCIES
  • NUGET_USEINPROCESSCLIENT
  • NUGET_CONFIGFILE
  • NUGET_SOURCE
  • any addin/module that potentially uses ICakeConfiguration.

Not used by frosting today

  • SETTINGS_SKIPVERIFICATION
  • PATHS_ADDINS
  • PATHS_MODULES

All above can already be configured with Frosting in release/1.0.0 using IServiceCollection UseCakeSetting(this IServiceCollection services, string key, string value), just not aligned with Cake/Cake.Tool/Cake.CoreCLR, which allows things to be configured through command-line, environment variables, and config file.

But 1.0.0-rc003 will add a SetToolPath method on the Cake host which can be used to set the tool path.

#3059 adds an UseToolPath(this IServiceCollection services, DirectoryPath toolPath) which naming more aligned with the rest of frosting extensions IMHO

@devlead devlead closed this as completed in fc502c2 Feb 7, 2021
@devlead devlead reopened this Feb 7, 2021
devlead added a commit to devlead/cake that referenced this issue Feb 7, 2021
* Frosting utilize CakeConfigurationProvider, enables config
    * Frosting IServiceCollection.UseToolPath
    * cake.config file
    * environment variables
    * command line arguments
* Tools path should be resolved using configuration
* fixes cake-build#2904
devlead added a commit to devlead/cake that referenced this issue Feb 13, 2021
* Frosting utilize CakeConfigurationProvider, enables config
    * Frosting IServiceCollection.UseToolPath
    * cake.config file
    * environment variables
    * command line arguments
* Tools path should be resolved using configuration
* fixes cake-build#2904
@devlead devlead modified the milestones: v1.1.0, v1.x Next Feb 13, 2021
devlead added a commit to devlead/cake that referenced this issue Feb 15, 2021
* Frosting utilize CakeConfigurationProvider, enables config
    * Frosting IServiceCollection.UseToolPath
    * cake.config file
    * environment variables
    * command line arguments
* Tools path should be resolved using configuration
* fixes cake-build#2904
devlead added a commit to devlead/cake that referenced this issue Feb 17, 2021
* Frosting utilize CakeConfigurationProvider, enables config
    * Frosting IServiceCollection.UseToolPath
    * cake.config file
    * environment variables
    * command line arguments
* Tools path should be resolved using configuration
* fixes cake-build#2904
devlead added a commit to devlead/cake that referenced this issue Feb 21, 2021
* Frosting utilize CakeConfigurationProvider, enables config
    * Frosting IServiceCollection.UseToolPath
    * cake.config file
    * environment variables
    * command line arguments
* Tools path should be resolved using configuration
* fixes cake-build#2904
devlead added a commit to devlead/cake that referenced this issue Feb 23, 2021
* Frosting utilize CakeConfigurationProvider, enables config
    * Frosting IServiceCollection.UseToolPath
    * cake.config file
    * environment variables
    * command line arguments
* Tools path should be resolved using configuration
* fixes cake-build#2904
augustoproiete added a commit that referenced this issue Feb 27, 2021
GH2904: Frosting cake.config&tool config support
@augustoproiete augustoproiete modified the milestones: v1.x Next, v1.1.0 Feb 27, 2021
@cake-build-bot
Copy link

🎉 This issue has been resolved in version v1.1.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants