diff --git a/Sakefile.shade b/Sakefile.shade new file mode 100644 index 0000000..ccf911b --- /dev/null +++ b/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' diff --git a/build b/build new file mode 100644 index 0000000..c7f3ed6 --- /dev/null +++ b/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" "$@" + diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..e2b46b0 --- /dev/null +++ b/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__= + diff --git a/src/Case01_ManyFrameworks/Properties/AssemblyInfo.cs b/src/Case01_ManyFrameworks/Properties/AssemblyInfo.cs index b809450..86dfa6d 100644 --- a/src/Case01_ManyFrameworks/Properties/AssemblyInfo.cs +++ b/src/Case01_ManyFrameworks/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -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")] diff --git a/src/Case02_JustGate/Case02_JustGate.csproj b/src/Case02_JustGate/Case02_JustGate.csproj index 88b8267..d9e030b 100644 --- a/src/Case02_JustGate/Case02_JustGate.csproj +++ b/src/Case02_JustGate/Case02_JustGate.csproj @@ -38,8 +38,8 @@ ..\..\packages\Gate.0.3.4\lib\net40\Gate.dll - - ..\..\packages\Gate.Builder.0.3.5\lib\net40\Gate.Builder.dll + + ..\..\packages\Gate.Builder.0.3.4\lib\net40\Gate.Builder.dll ..\..\packages\Gate.Hosts.AspNet.0.3.4\lib\net40\Gate.Hosts.AspNet.dll diff --git a/src/Case02_JustGate/Properties/AssemblyInfo.cs b/src/Case02_JustGate/Properties/AssemblyInfo.cs index f6f7ebc..463a432 100644 --- a/src/Case02_JustGate/Properties/AssemblyInfo.cs +++ b/src/Case02_JustGate/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -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")] diff --git a/src/Case02_JustGate/Startup.cs b/src/Case02_JustGate/Startup.cs index 83cd2bd..7218557 100644 --- a/src/Case02_JustGate/Startup.cs +++ b/src/Case02_JustGate/Startup.cs @@ -7,13 +7,28 @@ public class Startup { public void Configuration(IAppBuilder builder) { - builder.RunDirect( - (req, res) => + builder + .Use(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); + }; } } } diff --git a/src/Case03_JustOwin/Properties/AssemblyInfo.cs b/src/Case03_JustOwin/Properties/AssemblyInfo.cs index 62bf0b8..a487640 100644 --- a/src/Case03_JustOwin/Properties/AssemblyInfo.cs +++ b/src/Case03_JustOwin/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -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")] diff --git a/src/Case03_JustOwin/Startup.cs b/src/Case03_JustOwin/Startup.cs index 2e2b3b2..8a1e525 100644 --- a/src/Case03_JustOwin/Startup.cs +++ b/src/Case03_JustOwin/Startup.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Text; using Owin; @@ -9,7 +10,9 @@ public class Startup { public void Configuration(IAppBuilder builder) { - builder.Use(_ => App); + builder + .Use(LogRequests) + .Use(_ => App); } private void App(IDictionary env, ResultDelegate result, Action fault) @@ -31,5 +34,16 @@ private void App(IDictionary 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); + }; + } } }