Replies: 1 comment 8 replies
-
There're other similar PoC approaches done i.e. Cake.Bridge which will let you have a Program.cs looking something like this using System.Linq;
using Cake.Common;
using Cake.Common.Diagnostics;
using Cake.Common.IO;
using Cake.Common.Tools.DotNetCore;
using Cake.Core;
using CakeConsoleRunner;
using static CakeBridge;
var target = Context.Argument<string>("target", "Build");
Setup(context =>
{
context.Information("Setting up...");
return new BuildData(
Context
.GetFiles("./src/*.sln")
.FirstOrDefault()
??
Context
.GetFiles("../../src/*.sln")
.FirstOrDefault()
??
Context
.GetFiles("../../../../*.sln")
.FirstOrDefault());
});
Teardown(context =>
{
context.Information("Tearing down...");
});
var restore = Task("Restore")
.Does<BuildData>(buildData =>
{
Context.DotNetCoreRestore(buildData.Solution.FullPath);
});
var build = Task("Build")
.IsDependentOn(restore)
.Does<BuildData>(buildData =>
{
Context.DotNetCoreBuild(buildData.Solution.FullPath);
});
RunTarget(target); And Cake.Bridge.DependencyInjection that takes the IoC route letting you do code like var serviceCollection = new ServiceCollection()
.AddCakeCore();
var serviceProvider = serviceCollection.BuildServiceProvider();
var scriptHost = serviceProvider.GetRequiredService<IScriptHost>();
scriptHost.Task("Hello")
.Does(ctx => ctx.Information("Hello"));
scriptHost.Task("World")
.IsDependentOn("Hello")
.Does(ctx => ctx.Information("World"));
await scriptHost.RunTargetAsync("World"); Both Cake.Bridge.DependencyInjection and Cake.Bridge are up on NuGet if one wants to take them for a spin. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context
I've been using cake for about 4 years at my current job. With about 25 micro-services being built & tested using cake, I think that we can say that the adoption is a great success. The fact that Cake is c# syntax was one of the key factor for adoption.
But even with these signs of success, many of my teammates are reluctant to contribute to our cake scripts. So we most often end-up with only a few folks that are ready to really get involved in the cake scripts. The push back that we get often looks like this:
I recently discovered that cake now has the
frosting
runner which will finally answer these questions with satifiying answers. Great job for this 👍Problem
I tried to migrate one of our cake scrpit and I quickly came to the conclusion that
frosting
is similar in terms of concepts (setup, teardown, tasks, dependencies) with the standard runner but the implementation is totally different. For example, let's say that I have a standard set of tasks like this:When I translate these in Frosing syntax, I end-up with something that looks like this:
This works fine but I think that it's not ideal for adoption of frosting. Here are the problems that I see:
FrostingTask
,AsyncFrostingTask
), the attributes, etc. If the programmer is not aware of these tools, intelli-sense will not help him to discover them after typing a.
following a method/property call. From my experience, a typical developer contributes to a cake scripts at most once every 3 months. So the number of things that he must know / remember should be minimal.Proposition
I looked at the code of frosting and came to the conclusion that these problems could be adressed by removing some syntactic sugar of Frosting (I don't like cake with too much frosing in real life as well 😉 ). This can easilly be done by using the
ICakeEngine
. I quickly hacked theICakedHost.Run
method to accept a callback that makes it possible to configure the cake engine with a syntax that is very very similar to the classic cake syntax. I tried to convert theCake.Frosting.Example
to this pattern. Here's what it looks like:Here's what I find interesting in this approach:
You may completely disagree with how I hacked the
ICakeHost.Run
method and that's ok. The goal of this discussion is not to agree on the how . The goal is to discuss about the concept of adding a simpler syntax to frosting. Also note that I am not talking about replacing the current Frosting strategy. I am just trying to discuss of a way to have best of both worlds:Thank you in advance for your time and also a huge thanks for creating cake. I just can't imagine anymore the days where we were working with
psake
or xml msbuild scripts. These were the dark days of the .net build system 😨Beta Was this translation helpful? Give feedback.
All reactions