by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:58
    nils-a commented #2868
  • 13:54
    nils-a closed #2869
  • 13:31
    Build #5936 passed
  • 13:27
    gep13 commented #2869
  • 13:24
    nils-a opened #2869
  • 13:19
    Build #5935 passed
  • 13:14
    nils-a synchronize #2789
  • 12:55
    nils-a commented #2868
  • 12:51
    nils-a opened #2868
  • Sep 28 20:56
    kcamp removed as member
  • Sep 28 20:35
    Build #96 passed
  • Sep 28 20:33
    Build #95 passed
  • Sep 28 14:11
    bhabermann starred cake-build/cake
  • Sep 28 06:56
    ecampidoglio commented #2863
  • Sep 27 23:27
    Build #5934 passed
  • Sep 27 23:22
    gitfool synchronize #2867
  • Sep 27 22:43
    gitfool commented #2624
  • Sep 27 22:39
    Build #5933 passed
  • Sep 27 22:34
    gitfool opened #2867
  • Sep 27 22:14
    gitfool opened #2866
Gary Ewan Park
@gep13
When you say that it isn't loading the *.cake files, what exactly is it that makes you think that?
Maciek Misztal
@mmisztal1980

@gep13 when running a build.cake which references the nuget package:

#load nuget:?package=CloudTek.Core.Build&version=0.0.1.2020092015

Build.System.Initialize(context: Context, buildSystem: BuildSystem);

Setup<Module>(context => {
    return new Module() {
        Name = "core",
        ModuleVersion = new ModuleVersion() {
            Version = @version,
            AssemblyVersion = @assemblyVersion
        },
        Artifacts = new Dictionary<string, Artifact> {
            { "core-pkg",               new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } },
            { "core-logging-pkg",       new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } },
            { "core-hosting-pkg",       new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } },
            { "core-metrics-pkg",       new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } },
            { "core-telemetry-pkg",     new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } },
            { "core-api-pkg",           new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } },
            { "core-caching-pkg",       new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } },
            { "core-domain-pkg",        new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } },
            { "core-testing-pkg",       new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } },
            { "core-servicebus-pkg",    new Artifact() { Type = ArtifactType.Package, Stability = Stability.Stable } }
        }
    };
});

RunTarget(Build.System.Target);

I'm getting a ton of errors like:

/Users/mmisztal/Projects/@cloud-technologies/core-pkg/tools/CloudTek.Core.Build.0.0.1.2020092015/Content/build.provider.github-actions.cake(73,40): 
error CS1061: 'BuildSystem' does not contain a definition for 'GitHubActions' and no accessible extension method 'GitHubActions' accepting a first argument of type 'BuildSystem' could be found (are you missing a using directive or an assembly reference?)
Users/mmisztal/Projects/@cloud-technologies/core-pkg/tools/CloudTek.Core.Build.0.0.1.2020092015/Content/build.provider.cake(76,60): 
error CS1061: 'BuildSystem' does not contain a definition for 'AzurePipelines' and no accessible extension method 'AzurePipelines' accepting a first argument of type 'BuildSystem' could be found (are you missing a using directive or an assembly reference?)
Gary Ewan Park
@gep13
Not that it should make a difference, but...
you have a BuildSystem instance here, any reason you aren't passing it into the Provider?
Maciek Misztal
@mmisztal1980
@gep13 not really, It's from a phase when I was analyzing the internals of Cake.Recipe . Anything wrong with passing the BuildSystem ? Doesn't it come from Cake ?
Gary Ewan Park
@gep13
It comes from Cake, yes.
Not really in a position to dive into this at the minute, so not sure I can offer too much just now
Maciek Misztal
@mmisztal1980
hmmm in that case the error messages are starting to become more puzzling to me :D
That's totally fine. Any idea where do the BuildSystem.GitHubActions / BuildSystem.AzurePipelines properties/members originate from? perhaps I'm missing an addin?
Maciek Misztal
@mmisztal1980
thank you! I'll give it a look
Kim J. Nordmo
@AdmiringWorm
From the looks of the error message, it sounds like you are using an older version of cake. Try updating the cake version and see if that helps.
I think the GitHubActions obe was added in cake 0.38 (or maybe 0.37)
Maciek Misztal
@mmisztal1980
@AdmiringWorm let me look into it
Maciek Misztal
@mmisztal1980

yup, that was it, dotnet tool update cake.tool --globalyielded:

Tool 'cake.tool' was successfully updated from version '0.33.0' to version '0.38.5'.

Cheers @AdmiringWorm

Maciek Misztal
@mmisztal1980
Stupid question: is it possible to invoke CakeTaskBuilder.IsDependentOn(string) during Setup ? @gep13 ?
Mattias Karlsson
@devlead
The dependency graph is already built during setup, so that's not advisable.
What you could do in setup is to setup a typed build context and use that with i.e. WithCriteria etc. to opt-in/out of running certain dependencies
Maciek Misztal
@mmisztal1980
@devlead I was toying with the idea of having a dynamically constructed task list - based on the list of modules that I'm providing in the Setup - is there an alternate way to hook in before Setup runs?
Mattias Karlsson
@devlead
Sure, create your own initialize method, and call it before RunTarget.
Maciek Misztal
@mmisztal1980
@devlead is it possible to retrieve the name of the currently executing Task? Preferably from the ICakeContext? I know it's possible via the TaskSetup and setupContext.Task.Name but I have not idea if I can persist it for the actual Task somehow?
Mattias Karlsson
@devlead

@mmisztal1980 no don't think there is, but you could do something like

public class TaskState
{
    public string LastTask { get; set; }
}

Setup(_ => new TaskState());
TaskSetup<TaskState>((context, state) => state.LastTask = context.Task.Name);

Action<ICakeContext, TaskState> outputRunningTask =
    (context, state)
        => context.Information("Hello from {0}", state.LastTask);

Task("Test 1")
    .Does(outputRunningTask);


Task("Test 2")
    .Does(outputRunningTask);


Task("Test 3")
    .Does(outputRunningTask);

Task("Test")
    .IsDependentOn("Test 1")
    .IsDependentOn("Test 2")
    .IsDependentOn("Test 3");

RunTarget("Test");

Will output something like

----------------------------------------
Setup
----------------------------------------

========================================
Test 1
========================================
Hello from Test 1

========================================
Test 2
========================================
Hello from Test 2

========================================
Test 3
========================================
Hello from Test 3

========================================
Test
========================================

Task                          Duration            
--------------------------------------------------
Setup                         00:00:00.0062559    
Test 1                        00:00:00.0057389    
Test 2                        00:00:00.0000890    
Test 3                        00:00:00.0000598    
--------------------------------------------------
Total:                        00:00:00.0121784
Maciek Misztal
@mmisztal1980
I see...
that explains things :D
Maciek Misztal
@mmisztal1980
@devlead is it possible to reference the ScriptHost in a .cake file?
Mattias Karlsson
@devlead
@mmisztal1980 what are you trying to solve?
Nick
@nick5454
is it possible to specify a custom GitVersion.yml file to use for the GitVersionSettings class? I want you use a custom GitVersion.yml class per project from a Core Cake nuget. Is there a way to specify which file to use?
Maciek Misztal
@mmisztal1980
@devlead I'm working on making a dynamically generated Task list - before RunTarget is invoked , I'm trying to figure out if I can reference ScriptHost.Task somehow
Maciek Misztal
@mmisztal1980

@devlead pretty much trying to get something like this to work:

public class Solution {
    public string CurrentTask { get; set; }
    public IDictionary<string, Module> Modules { get; set; } = new Dictionary<string, Module>();
    public IDictionary<string, IDictionary<string, CakeTaskBuilder>> ModuleTasks = new Dictionary<string, IDictionary<string, CakeTaskBuilder>>();
}

public static class BuildSystem 
{
       // (...)
        private static void InitializeNuGetTasks(Solution solution)
        {
            solution.Modules.ForEach(module => {
                var task = $"{module.Key}-pack";
                solution.ModuleTasks[module.Key][task] = Task(task).Does(ctx => {
                    ctx.Information($"Inside {task}");
                });
            });
        }
}

but I'm getting

error CS0120: An object reference is required for the non-static field, method, or property 'ScriptHost.Task(string)'

Any suggestions? I guess this is where I need to reference the ScriptHost somehow

Mattias Karlsson
@devlead
Issue is that as soon as your in a class or going static you're leaving the script default scope, so you'll need to pass a reference to something, i.e. Cake context to use aliases. Not at computer so unsure about obtaining whole context, but you could always pass task method as an action to use it later on.
Mattias Karlsson
@devlead
Example
public class MyOutOfScopeClass
{
    public static void AddTasks(Func<string, CakeTaskBuilder> task)
    {
        task("One");
        task("Two")
            .IsDependentOn("One");
        task("Three")
            .IsDependentOn("Two");
    }
}

MyOutOfScopeClass.AddTasks(Task);

RunTarget("Three");
Mattias Karlsson
@devlead
In your case it could be something like
 static void InitializeNuGetTasks(Func<string, CakeTaskBuilder> Task, Solution solution)
    {
        solution.Modules.ForEach(module => {
            var task = $"{module.Key}-pack";
            solution.ModuleTasks[module.Key][task] = Task(task).Does(ctx => {
                ctx.Information($"Inside {task}");
            });
        });
    }
Maciek Misztal
@mmisztal1980
can't I reference the ScriptHost using this or something like that - being in the outermost .cake scope?
your solution would totally work, however it contradicts my goal - I don't want to define Task(s) per build.cake - I want my microservices to all share a standard build-system with self-generating tasks (which is going to be based on the solution's structure - which is pretty standardized at the moment)
Mattias Karlsson
@devlead
Not following 100%, there's no this in a Roslyn script object, it only makes its members available, but don't see the semantic difference of passing this and calling Task on that object VS. passing a reference to Task and invoking it. You don't need to define the tasks in each build.cake you just need to bootstrap/start the process that does that, and even that code could be triggered in another script, so there's just a #load for the common bits.
Maciek Misztal
@mmisztal1980
Hmmm you’re right - I’m going to try that today
Nick
@nick5454
Has anyone been able to get GitVersion to work on macos?
Mattias Karlsson
@devlead
@nick5454 yes, Cake itself uses it. We use the global tool.
Morten Larsen
@Baune8D
Is it just me or is the .NET Core tool completely broken when using —target? This command: "dotnet cake —target Build” gives the following error: “More than one build script specified"
Nils Andresen
@nils-a
@Baune8D the syntax is --target=Build ;-)
Morten Larsen
@Baune8D
@nils-a Oh okey, will try that. Its just that the command “dotnet cake —help” shows this:
--target <TARGET> Target task to invoke. Script must support this explicitly.
Nils Andresen
@nils-a
@Baune8D yes - I saw that, too. Interesting. I knew I stumbled over the "=" before therefore I answered the way I did. But now.. I'm guessing --help is wrong. For --verbosity the equal-sign is mentioned.
Morten Larsen
@Baune8D
@nils-a yes i also just tested it —target=<TARGET> works
Maciek Misztal
@mmisztal1980
works fine
Nils Andresen
@nils-a
@Baune8D or what it's worth, this seemingly got mixed up in cake-build/cake#2605. Note that the very first line of help is correctly showing --target=value.
Nick
@nick5454
@devlead I get this error " Could not find an installer for the 'dotnet' scheme.". How do I register the dotnet scheme in my cake project?
Kim J. Nordmo
@AdmiringWorm

@nick5454 restoring/installing .NET Core tools is not provided by cake core, it is provided by a separate module called Cake.DotNetTool.Module.

The way to use it would be to have the following reference in the cake build:

#module nuget:?package=Cake.DotNetTool.Module&version=0.4.0

You then need to call cake with the following argument --bootstrap before you do the actual running of the build script.
For instance, if you use the cake global tool, it would be something along the lines of

dotnet cake build.cake --bootstrap
dotnet cake build.cake

You can omit build.cake as that is the default script name, just included it to be complete

Mattias Karlsson
@devlead
With upcoming Cake 1.0 bootstrapping will be implicit so just dotnet cake will be enough