-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.csx
93 lines (78 loc) · 2.18 KB
/
build.csx
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
90
91
92
93
using System.Text.RegularExpressions;
var target = Argument("target", "NuGet");
var config = Argument("config", "Release");
var output = "./build";
var version = ParseVersion("./src/OrigoDB.Modules.EventStore/Properties/AssemblyInfo.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("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore("./src/OrigoDB.Modules.EventStore.sln");
});
Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
MSBuild("./src/OrigoDB.Modules.EventStore/OrigoDB.Modules.EventStore.csproj", settings =>
settings.SetConfiguration(config)
.UseToolVersion(MSBuildToolVersion.VS2012)
.WithTarget("clean")
.WithTarget("build"));
});
Task("Copy")
.IsDependentOn("Build")
.Does(() =>
{
var pattern = "src/OrigoDB.*/bin/" + config + "/OrigoDB.*.dll";
CopyFiles(pattern, output);
});
Task("Zip")
.IsDependentOn("Copy")
.Does(() =>
{
var root = "./build/";
var output = "./build/OrigoDB.Modules.EventStore.binaries." + version + "-" + config + ".zip";
var files = root + "/*";
// Package the bin folder.
Zip(root, output);
});
Task("NuGet")
.IsDependentOn("Zip")
.Does(() =>
{
NuGetPack("./OrigoDB.EventStore.nuspec", new NuGetPackSettings {
Version = version,
OutputDirectory = "./build",
Symbols = true
});
});
////////////////////////////////////////////////
// RUN TASKS
////////////////////////////////////////////////
RunTarget(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;
}
}