-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.cake
89 lines (78 loc) · 2.44 KB
/
build.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configs = new string[] { "NET40", "NET35" };
var version = string.Format("0.7.{0}.{1}"
, (int)((DateTime.UtcNow - new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalDays)
, (int)((DateTime.UtcNow - DateTime.UtcNow.Date).TotalSeconds / 2));
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
DeleteFiles("./ODataToolkit.*.nupkg");
EnsureDirectoryExists("./artifacts");
CleanDirectory("./publish/ODataToolkit/lib");
CleanDirectory("./artifacts");
});
Task("Patch-Version")
.IsDependentOn("Clean")
.Does(() =>
{
var file = "./ODataToolkit/Properties/AssemblyInfo.cs";
var info = ParseAssemblyInfo(file);
CreateAssemblyInfo(file, new AssemblyInfoSettings {
Product = "ODataToolkit",
Version = version,
FileVersion = version,
Description = "Toolkit for developing OData web services. Can be used from Web API, Nancy, or the platform of your choice."
});
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Patch-Version")
.Does(() =>
{
NuGetRestore("./ODataToolkit.sln");
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
foreach (var config in configs)
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./ODataToolkit/ODataToolkit.csproj", settings =>
settings.SetConfiguration(config));
}
else
{
// Use XBuild
XBuild("./ODataToolkit/ODataToolkit.csproj", settings =>
settings.SetConfiguration(config));
}
}
});
Task("NuGet-Pack")
.IsDependentOn("Build")
.Does(() =>
{
var nuGetPackSettings = new NuGetPackSettings {
Version = version,
OutputDirectory = "./artifacts"
};
NuGetPack("./publish/ODataToolkit/ODataToolkit.nuspec", nuGetPackSettings);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("NuGet-Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);