question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use cake build language in classes

See original GitHub issue

I’d like to structure my build scripts into different classes. E.g one for default directory definitions. I noticed that I’m not able to use the cake build language there e.g.

public class DefaultDirectories
{   
    public static DirectoryPath WorkingCopyRoot = MakeAbsolute(Directory(".")) 
    public static DirectoryPath Binaries = WorkingCopyRoot.Combine(new DirectoryPath("bin"));
 ...
}

MakeAbsolute and Directory cannot be interpreted correctly by CAKE.

For now I created a workaround but that may be not possible for other cases

public class DefaultDirectories
{   
    public static DirectoryPath WorkingCopyRoot = new DirectoryPath(System.IO.Directory.GetCurrentDirectory());
    public static DirectoryPath Binaries = WorkingCopyRoot.Combine(new DirectoryPath("bin"));
    ...
}

Do I miss something or is that not intended to be done like that?

Another newbie question: How do you edit your build scripts, can this be done somehow in Visual Studio where compilation errors might be shown as under normal C# development?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
patriksvenssoncommented, Aug 29, 2015

Alas, there are no plans of supporting Cake alias methods in classes. A workaround for your problem would be something like this:

public class DefaultDirectories
{
    public static DirectoryPath WorkingCopyRoot;
    public static DirectoryPath Binaries;

    public static void Initialize(ICakeContext c)
    {
      WorkingCopyRoot = c.MakeAbsolute(c.Directory("./"));
      Binaries = WorkingCopyRoot.Combine(new DirectoryPath("bin"));
    }
}

// Initialize default directories.
DefaultDirectories.Initialize(Context);

Task("DoMagic")
  .Does(() =>
{
  var temp = DefaultDirectories.WorkingCopyRoot.Combine("tmp");
  Information(temp.FullPath);
});

RunTarget("DoMagic");
0reactions
Sam13commented, Sep 2, 2015

That’s fine, didn’t know how to adress the context…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cake Build
Cake supports the most common tools used during builds such as MSBuild, .NET Core CLI, MSTest, xUnit, NUnit, NuGet, ILMerge, WiX and SignTool...
Read more >
Reference
This reference guide describes the various methods and properties which make up the Cake build language, or DSL. The DSL is made up...
Read more >
Building and Deploying Applications with Cake
This course will teach you how to use Cake to compile, test, version, package, and deploy your .NET or .NET Core application.
Read more >
Using Cake build scripts for your .NET Core web apps
Cake is a build automation system for .NET Developers to script their build processes using a C# Domain Specific Language (DSL).
Read more >
Cake Build Tool
The Cake build tool is a build tool that utilizes the Roslyn ... can write very precise build scripts using very familiar C#...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found