Skip to content

Instantly share code, notes, and snippets.

@patriksvensson
Created August 29, 2016 07:40
Show Gist options
  • Save patriksvensson/c1873e0353c408f116bd58e9cf687919 to your computer and use it in GitHub Desktop.
Save patriksvensson/c1873e0353c408f116bd58e9cf687919 to your computer and use it in GitHub Desktop.
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="myget.org" value="https://www.myget.org/F/cake/api/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
using System;
using Cake.Common.Diagnostics;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Frosting;
public class Program
{
public static int Main(string[] args)
{
// Create the host.
var host = new CakeHostBuilder()
.WithArguments(args)
.UseStartup<MyStartup>()
.Build();
// Run the host.
return host.Run();
}
}
public class MyStartup : IFrostingStartup
{
public void Configure(ICakeServices services)
{
services.UseContext<MySettings>();
}
}
public class MySettings : FrostingContext
{
public bool Magic { get; set; }
public MySettings(ICakeContext context)
: base(context)
{
// You could also use a CakeLifeTime<Settings>
// to provide a Setup method to setup the context.
Magic = context.Arguments.HasArgument("magic");
}
}
[TaskName("Provide-Another-Name-Like-This")]
public class Build : FrostingTask<MySettings>
{
public override bool ShouldRun(MySettings context)
{
// Don't run this task on OSX.
return context.Environment.Platform.Family != PlatformFamily.OSX;
}
public override void Run(MySettings context)
{
context.Information("Magic: {0}", context.Magic);
}
}
[Dependency(typeof(Build))]
public class Default : FrostingTask
{
// If you don't inherit from the generic task
// the standard ICakeContext will be provided.
}
{
"version": "0.1.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Autofac": "4.1.0",
"Cake.Frosting": "0.1.0-alpha0006",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [ "dnxcore50" ]
}
},
"tools": {
"Cake.Frosting.Cli": "0.1.0-alpha0006"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment