pitermarx / cake.console Goto Github PK
View Code? Open in Web Editor NEWA Cake Console app without Frosting
License: MIT License
A Cake Console app without Frosting
License: MIT License
install dotnet-script
run dotnet script .\dotnet-script\test.csx
warn: Dotnet.Script.Core.Commands.ExecuteScriptCommand[0]
The script C:\github\Cake.Console\.\dotnet-script\test.csx is not cacheable. For caching and optimal performance, ensure that the script only contains NuGet references with pinned/exact versions.
warn: Dotnet.Script.DependencyModel.Context.CachedRestorer[0]
Unable to cache C:\Users\PedroMarques\AppData\Local\Temp\dotnet-script\C\github\Cake.Console\.\dotnet-script\net5.0\script.csproj. For caching and optimal performance, ensure that the script(s) references Nuget packages with a
pinned version.
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (0x80131621)
File name: 'Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60'
---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)
at System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(RuntimeAssembly assembly, String assemblyFullName)
at Cake.Console.CakeHostBuilder.BuildScriptHost[T](ICakeArguments args)
at Cake.Console.CakeHostBuilder.BuildHost(IEnumerable`1 args)
at Submission#0.<<Initialize>>d__0.MoveNext() in C:\github\Cake.Console\dotnet-script\test.csx:line 9
--- End of stack trace from previous location ---
at Dotnet.Script.Core.ScriptRunner.Execute[TReturn](String dllPath, IEnumerable`1 commandLineArgs) in C:\Users\VssAdministrator\AppData\Local\Temp\tmpBFB\Dotnet.Script.Core\ScriptRunner.cs:line 110
Both Cake scripting and Frosting use Spectre.Console and now that Cake.CLI is used that dependency already exists in the project.
This would solve #3 too.
To align with Cake maybe Frosting's settings could be a good starting point
https://github.com/cake-build/cake/blob/b8c287aea1f084be96ffca9d82587e41e8a582da/src/Cake.Frosting/Internal/Commands/DefaultCommandSettings.cs#L13-L54
internal sealed class DefaultCommandSettings : CommandSettings
{
[CommandOption("--target|-t <TARGET>")]
[DefaultValue("Default")]
[Description("Target task to invoke.")]
public string Target { get; set; }
[CommandOption("--working|-w <PATH>")]
[TypeConverter(typeof(Cli.DirectoryPathConverter))]
[Description("Sets the working directory")]
public DirectoryPath WorkingDirectory { get; set; }
[CommandOption("--verbosity|-v <VERBOSITY>")]
[Description("Specifies the amount of information to be displayed.\n(Quiet, Minimal, Normal, Verbose, Diagnostic)")]
[TypeConverter(typeof(VerbosityConverter))]
[DefaultValue(Verbosity.Normal)]
public Verbosity Verbosity { get; set; }
[CommandOption("--description|--descriptions|--showdescription|--showdescriptions")]
[Description("Shows description for each task.")]
public bool Description { get; set; }
[CommandOption("--tree|--showtree")]
[Description("Shows the task dependency tree.")]
public bool Tree { get; set; }
[CommandOption("--dryrun|--noop|--whatif")]
[Description("Performs a dry run.")]
public bool DryRun { get; set; }
[CommandOption("--exclusive|-e")]
[Description("Executes the target task without any dependencies.")]
public bool Exclusive { get; set; }
[CommandOption("--version|--ver")]
[Description("Displays version information.")]
public bool Version { get; set; }
[CommandOption("--info")]
[Description("Displays additional information about Cake.")]
public bool Info { get; set; }
}
Frosting's default command could be used as inspiration on how Spectre.Console parsed commands are passed to Frosting
https://github.com/cake-build/cake/blob/b8c287aea1f084be96ffca9d82587e41e8a582da/src/Cake.Frosting/Internal/Commands/DefaultCommand.cs#L30
And here how it's done in Cake scripting engine
https://github.com/cake-build/cake/blob/a1893a2bba26f49e089d66beeb78421cedf6126d/src/Cake/Infrastructure/ContainerConfigurator.cs#L28
Generics could be resolved
foreach (var behaviour in provider.GetServices<IHostBuilderBehaviour>())
{
host.Context.Debug($"Applying {behaviour.GetType().Name}");
behaviour.Run();
}
Exepected to log SetupContextDataBehaviour instead of SetupContextDataBehaviour`1
It would be great with an example showing how to get started with Cake.Console
.
Currently, the project lacks a license.
Cake itself uses MIT i.e., and most addins do, but obviously totally up to the author.
But for people to try & adopt, it's good practice to have a license in the repo.
Currently is very naive
args.Select(a => a.Replace("-", string.Empty).Split("="))
.ToDictionary(
pair => pair[0],
pair => pair.Length > 1 ? pair[1] : "true");
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.