Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cake

 Cake

A talk I gave at SWENUG in Stockholm 10 September, 2015.

Avatar for Patrik Svensson

Patrik Svensson

September 13, 2015

Other Decks in Programming

Transcript

  1. AGENDA • What is Cake? • The philosophy behind Cake

    • Dependency based programming • Cake scripts • Demo! • Questions 2
  2. WHAT IS CAKE? (1/2) • A build automation system with

    a C# DSL. • Supports the most common tools out of the box. • MSBuild, XBuild • NuGet (Pack, Push, Install, Restore, Update) • xUnit, NUnit, MSTest, Fixie • WiX, NSIS • Octopus Deploy • TeamCity, AppVeyor • Many more :) • Cross platform (Windows, OS X, Linux) 3
  3. 4 • Open source • Available on GitHub
 https://github.com/cake-build/cake •

    Small but slowly growing • 200+ pull requests • 21 contributors • About 15 third party addins
 PowerShell, IIS, Slack, WebDeploy, Xamarin, Unity3D etc. etc. • Awesome! ;-) WHAT IS CAKE? (2/2)
  4. PHILOSOPHY BEHIND CAKE (1/2) • Easy to use! • Convention

    based… • How tools are resolved • It should just work • …But configurable • Provide your own configuration • Implement your own tools • Replace parts you don’t like 5
  5. PHILOSOPHY BEHIND CAKE (2/2) • Non-intrusive • Doesn’t affect the

    way you or your team work • Sneak it in without anyone noticing (until it’s too late) • No binaries in repository • Bootstrap via a NuGet source • Behaves the same way • Regardless of operating system • Regardless of environment (i.e. TeamCity, AppVeyor, TFS, Jenkins, Bamboo) 6
  6. DEPENDENCY BASED PROGRAMMING Define your work as fine grained tasks.

    7 Build Unit tests FxCop StyleCop Clean Package Publish
  7. DEPENDENCY BASED PROGRAMMING Order of execution is defined as dependencies


    between tasks. 8 Build Unit tests FxCop StyleCop Clean Package Publish
  8. DEPENDENCY BASED PROGRAMMING Conditions influence whether a task should be

    skipped or not. 9 Build Unit tests FxCop StyleCop Clean Package Publish
  9. DEPENDENCY BASED PROGRAMMING By executing a target, we determine what

    tasks should be executed. 10 Build Unit tests FxCop StyleCop Clean Package Publish AppVeyor Default
  10. CAKE SCRIPTING 15 Task("Build") .IsDependentOn("Clean") .Does(() => { MSBuild("./src/Project.sln"); })

    .OnError(exception => { Error("An error occurred while building!"); throw exception; }) .Finally(() => { Debug("Done building."); });
  11. CAKE SCRIPTING 16 Task("Build") .IsDependentOn("Clean") .Does(() => { MSBuild("./src/Project.sln"); })

    .ReportError(exception => { Error("An error occurred while building!"); }) .Finally(() => { Debug("Done building."); });
  12. Task("Build") .IsDependentOn("Clean") .WithCriteria(() => DateTime.Now.Second % 2 == 0) .ContinueOnError()

    .Does(() => { MSBuild("./src/Project.sln"); }) .Finally(() => { Debug("Done building."); }); CAKE SCRIPTING 18