Skip to content

Commit

Permalink
Adding Sakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
lodejard committed May 10, 2012
1 parent 56e8009 commit 8e43978
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 18 deletions.
45 changes: 45 additions & 0 deletions Sakefile.shade
@@ -0,0 +1,45 @@
use-standard-lifecycle

use namespace="System"
use namespace="System.IO"
use import="Files"

var VERSION='0.1.0'
var FULL_VERSION='${VERSION}-alpha-1'
var AUTHORS='OWIN contributors'

var KATANA_VERSION='0.1.1'
var CORAL_VERSION='0.0.1'

var BASE_DIR='${Directory.GetCurrentDirectory()}'
var TARGET_DIR='${Path.Combine(BASE_DIR, "target")}'
var BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}'

var HOME_DIR='${Environment.GetEnvironmentVariable("HOME")}'
set HOME_DIR='${Environment.GetEnvironmentVariable("HOMEDRIVE") + Environment.GetEnvironmentVariable("HOMEPATH")}' if='string.IsNullOrEmpty(HOME_DIR)'

#delete-target-dir target='clean'
directory delete='${TARGET_DIR}'

#assembly-version target='initialize'
assemblyinfo each='var updateFile in Files.Include("src/**/AssemblyInfo.cs")' assemblyVersion='${VERSION}' assemblyInformationalVersion='${FULL_VERSION}'

#build-sln target='compile'
build each='var projectFile in Files.Include("src/**/*.csproj")' configuration='Release'

#start .compile
nuget-install package='Katana' packageVersion='${KATANA_VERSION}' outputDir='packages'
nuget-install package='Coral' packageVersion='${CORAL_VERSION}' outputDir='packages'
var katanaProgram='${BASE_DIR}\packages\Katana.${KATANA_VERSION}\bin\Katana.exe'
var coralProgram='${BASE_DIR}\packages\Coral.${CORAL_VERSION}\bin\Coral.exe'
@{
var port = 3000;
var text = Files.Include("src/**/Startup.cs")
.Select(x=>Path.GetDirectoryName(x))
.Select(x=>new {path=x, name=Path.GetFileName(x)})
.Select(x=>string.Format("{0}: cd {1} && {2} --server firefly --port {3}", x.name, x.path, katanaProgram, ++port))
.Aggregate("", (a,b) => a + "\r\n" + b);
Log.Info(string.Format("Writing Coral.txt\r\n{0}", text));
File.WriteAllText("Coral.txt", text);
}
exec-clr program='${coralProgram}' commandline='start'
6 changes: 6 additions & 0 deletions build
@@ -0,0 +1,6 @@
#!/bin/sh

export EnableNuGetPackageRestore=true
mono --runtime=v4.0 "./.nuget/NuGet.exe" install Sake -pre -o packages
mono $(find packages/Sake.*/tools/Sake.exe|sort -r|head -n1) -I "src/Sake.Library/Shared" "$@"

10 changes: 10 additions & 0 deletions build.cmd
@@ -0,0 +1,10 @@
@echo off
cd %~dp0

set EnableNuGetPackageRestore=true
".nuget\NuGet.exe" install Sake -pre -o packages

for /f "tokens=*" %%G in ('dir /AD /ON /B "packages\Sake.*"') do set __sake__=%%G
"packages\%__sake__%\tools\Sake.exe" -I src\Sake.Library\Shared %*
set __sake__=

6 changes: 3 additions & 3 deletions src/Case01_ManyFrameworks/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -27,5 +27,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.1.0")]
[assembly: AssemblyFileVersion("0.1.0")]
4 changes: 2 additions & 2 deletions src/Case02_JustGate/Case02_JustGate.csproj
Expand Up @@ -38,8 +38,8 @@
<Reference Include="Gate, Version=0.3.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Gate.0.3.4\lib\net40\Gate.dll</HintPath>
</Reference>
<Reference Include="Gate.Builder, Version=0.3.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Gate.Builder.0.3.5\lib\net40\Gate.Builder.dll</HintPath>
<Reference Include="Gate.Builder, Version=0.3.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Gate.Builder.0.3.4\lib\net40\Gate.Builder.dll</HintPath>
</Reference>
<Reference Include="Gate.Hosts.AspNet, Version=0.3.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Gate.Hosts.AspNet.0.3.4\lib\net40\Gate.Hosts.AspNet.dll</HintPath>
Expand Down
6 changes: 3 additions & 3 deletions src/Case02_JustGate/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -27,5 +27,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.1.0")]
[assembly: AssemblyFileVersion("0.1.0")]
27 changes: 21 additions & 6 deletions src/Case02_JustGate/Startup.cs
Expand Up @@ -7,13 +7,28 @@ public class Startup
{
public void Configuration(IAppBuilder builder)
{
builder.RunDirect(
(req, res) =>
builder
.Use<AppTaskDelegate>(LogRequests)
.RunDirect(App);
}

private void App(Request req, Response res)
{
res.ContentType = "text/plain";
res.Write("You did a {0} at {1}", req.Method, req.Path);
res.End();
}

private AppTaskDelegate LogRequests(AppTaskDelegate app)
{
return
env =>
{
res.ContentType = "text/plain";
res.Write("You did a {0} at {1}", req.Method, req.Path);
res.End();
});
var req = new Request(env);
req.TraceOutput.WriteLine("{0} {1}", req.Method, req.Path);
return app(env);
};
}
}
}
6 changes: 3 additions & 3 deletions src/Case03_JustOwin/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -27,5 +27,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.1.0")]
[assembly: AssemblyFileVersion("0.1.0")]
16 changes: 15 additions & 1 deletion src/Case03_JustOwin/Startup.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Owin;

Expand All @@ -9,7 +10,9 @@ public class Startup
{
public void Configuration(IAppBuilder builder)
{
builder.Use<AppDelegate>(_ => App);
builder
.Use<AppTaskDelegate>(LogRequests)
.Use<AppDelegate>(_ => App);
}

private void App(IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault)
Expand All @@ -31,5 +34,16 @@ private void App(IDictionary<string, object> env, ResultDelegate result, Action<
end(null);
});
}

private AppTaskDelegate LogRequests(AppTaskDelegate app)
{
return
env =>
{
var log = (TextWriter)env["host.TraceOutput"];
log.WriteLine("{0} {1}", env["owin.RequestMethod"], env["owin.RequestPath"]);
return app(env);
};
}
}
}

0 comments on commit 8e43978

Please sign in to comment.