Coder Social home page Coder Social logo

cake-example's Introduction

#TL;DR To see how easy it is to get a build running with Cake

  • Clone this repo (which has no Cake files)

  • Run this powershell to get the 2 files required to bootstrap the build:

     "build.ps1","build.cake"|%{Invoke-RestMethod -Uri "https://raw.githubusercontent.com/cake-build/bootstrapper/master/res/scripts/$($_)" -OutFile $_}
  • Run the PS script ./Build.ps1

Note, you don't have to use powershell to use Cake. I just love that I can add 2 small files to my repo and that's all I need for the build process to work.

#The slightly longer version

Here's some info about Cake:

Cake (C# Make) is a build automation system with a C# DSL to do things like compiling code, copy files/folders, running unit tests, compress files and build NuGet packages.

Build status Coverity Scan

Follow @cakebuildnet

cakebuild.net

Join the chat at https://gitter.im/cake-build/cake

##So what's this Repo?

I have just started using Cake and it took me a little (not long) time to figure out what I needed to start my build process. It turns out that it's hardly anything and the steps are simple. This is my attempt to document that.

This repo has a very simple Hello World C# Console solution with a Nuget dependency (log4net). It has no build scripts or any Cake-related files.

By following these steps you can have it building with Cake in a few minutes

###1. Clone this repo if you haven't already. ###2. Get the required files You need 2 files for a build (these will all you'll have to commit to you repo to use Cake):

  • build.ps1
    • This is a bootstrapper powershell script that ensures you have Cake and required dependencies installed.
  • build.cake
    • This is the actual build script. It doesn't have to be named this but this will be found by default.

An easy way to get these files is to download them using powershell. Open powershell, CD to the root of your repo and execute this command (this will not execute the powershell script, just download it):

"build.ps1","build.cake"|%{Invoke-RestMethod -Uri "https://raw.githubusercontent.com/cake-build/bootstrapper/master/res/scripts/$($_)" -OutFile $_}

This downloads the files from Cake Bootstrapper Other ways to get the files can be found on the Getting Started page on cakebuild.net ###3. Run the build script Still in powershell execute the script.

.\build.ps1

The script will detect that you don't have cake and download it. It will then run the very simple build.cake script that finds any .sln in files in or below the current folder, restores any NuGet dependencies, and builds them.

Congratulations, you've run you first Cake script!

###4. Bonus points! - run the tests The script is a fairly bare-bones implementation. But extending it is easy. For instance to run the extensive unit tests for the awesome application you need to add a test target:

Task("Run-Unit-Tests")
    .IsDependentOn("Build")
    .Does(() =>
{
    MSTest("./src/**/bin/" + configuration + "/*Test.dll");
});

This is using MSTest but out of the box you have XUnit and NUnit test helpers as well.

Adding the target doesn't necessarily run it unless another target is dependent on it or you call it explicitly.

In our case we can just change the default task to be dependent on our test task (which in turn is dependent on the build task):

Task("Default")
    .IsDependentOn("Run-Unit-Tests");

Running the build now will run the tests after building...

.\build.ps1

cake-example's People

Contributors

marcosnz avatar

Watchers

James Cloos avatar Richard Borges avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.