Skip to content

Commit

Permalink
added cake build support
Browse files Browse the repository at this point in the history
  • Loading branch information
rofr committed Jun 13, 2014
1 parent 58e2335 commit 98a3e17
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 0 deletions.
22 changes: 22 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo off

:Build
cls

echo Restoring NuGet packages for solution...
"nuget.exe" "restore" "src/OrigoDB.sln"
echo.

if not exist tools\Cake\Cake.exe (
echo Installing Cake...
nuget.exe install Cake -OutputDirectory tools -ExcludeVersion -NonInteractive
echo.
)

SET BUILDMODE="Release"
IF NOT [%1]==[] (set BUILDMODE="%1")

echo Starting Cake...
"tools\Cake\Cake.exe" "build.csx" "-verbosity=verbose" "-config=%BUILDMODE%"

exit /b %errorlevel%
84 changes: 84 additions & 0 deletions build.csx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System.Text.RegularExpressions;

var target = Argument("target", "NuGet");
var config = Argument("config", "Release");
var output = "./build";
var version = ParseVersion("./src/SharedAssemblyInfo.cs");

if(version == null)
{
// We make sure the version is set.
throw new InvalidOperationException("Could not parse version.");
}

////////////////////////////////////////////////
// TASKS
////////////////////////////////////////////////

Task("Clean")
.Does(() =>
{
CleanDirectory(output);
});

Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
MSBuild("./src/OrigoDB.sln", settings =>
settings.SetConfiguration(config)
.UseToolVersion(MSBuildToolVersion.VS2012)
.WithTarget("clean")
.WithTarget("build"));
});

Task("Copy")
.IsDependentOn("Build")
.Does(() =>
{
var pattern = "src/OrigoDB.*/bin/" + config + "/OrigoDB.*";
CopyFiles(pattern, output);
});

Task("Zip")
.IsDependentOn("Copy")
.Does(() =>
{
var root = "./build/";
var output = "./build/OrigoDB.Core.binaries." + version + "-" + config + ".zip";
var files = root + "/*";
// Package the bin folder.
Zip(root, output);
});

Task("NuGet")
.IsDependentOn("Zip")
.Does(() =>
{
NuGetPack("./OrigoDB.Core.nuspec", new NuGetPackSettings {
Version = version,
OutputDirectory = "./build"
});
});

////////////////////////////////////////////////
// RUN TASKS
////////////////////////////////////////////////

Run(target);

////////////////////////////////////////////////
// UTILITIES
////////////////////////////////////////////////

private string ParseVersion(string filename)
{
var file = FileSystem.GetFile(filename);
using(var reader = new StreamReader(file.OpenRead()))
{
var text = reader.ReadToEnd();
Regex regex = new Regex(@"AssemblyVersion\(""(?<theversionnumber>\d+\.\d+\.\d+)""\)");
return regex.Match(text).Groups["theversionnumber"].Value;
}
}
Binary file added tools/Cake/Cake.Common.dll
Binary file not shown.
Binary file added tools/Cake/Cake.Core.dll
Binary file not shown.
Binary file added tools/Cake/Cake.exe
Binary file not shown.
20 changes: 20 additions & 0 deletions tools/Cake/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2014 Patrik Svensson

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file added tools/Cake/NuGet.Core.dll
Binary file not shown.
Binary file added tools/Cake/Roslyn.Compilers.CSharp.dll
Binary file not shown.
Binary file added tools/Cake/Roslyn.Compilers.dll
Binary file not shown.
Binary file added tools/nuget/NuGet.exe
Binary file not shown.

0 comments on commit 98a3e17

Please sign in to comment.