-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.cake
97 lines (80 loc) · 2.97 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
90
91
92
93
94
95
96
97
#addin nuget:?package=Cake.Git
var gitRepository = "https://github.com/AeonLucid/POGOProtos.git";
var branch = EnvironmentVariable("POGOPROTOS_TAG") ?? "master";
var dirProtos = "./POGOProtos";
var dirTools = "./tools";
var dirSource = "./src";
var dirSourceCopy = "./srcCopy";
Information(branch);
Task("Clean").Does(() => {
if (DirectoryExists(dirProtos)) {
DeleteDirectory(dirProtos, true);
}
if (DirectoryExists(dirSourceCopy)) {
DeleteDirectory(dirSourceCopy, true);
}
});
Task("Copy").Does(() => {
CopyDirectory(dirSource, dirSourceCopy);
});
Task("POGOProtos-Tools").Does(() => {
NuGetInstall("Google.Protobuf.Tools", new NuGetInstallSettings {
ExcludeVersion = true,
OutputDirectory = dirTools,
Version = "3.3.0"
});
});
Task("POGOProtos-Clone").Does(() => {
Information("Cloning branch '" + branch + "'...");
StartProcess("git.exe", new ProcessSettings()
.WithArguments(args =>
args.Append("clone")
.Append("--quiet")
.Append("--branch")
.AppendQuoted(branch)
.Append(gitRepository)
.Append("POGOProtos")));
});
Task("POGOProtos-Compile").Does(() => {
StartProcess("C:/Python27/python.exe", new ProcessSettings()
.WithArguments(args =>
args.AppendQuoted(System.IO.Path.GetFullPath(dirProtos + "/compile.py"))
.Append("-p")
.AppendQuoted(System.IO.Path.GetFullPath(dirTools + "/Google.Protobuf.Tools/tools/windows_x64/protoc.exe"))
.Append("-o")
.AppendQuoted(System.IO.Path.GetFullPath(dirProtos + "/out"))
.Append("csharp")));
});
Task("POGOProtos-Move").Does(() => {
CopyDirectory(dirProtos + "/out/POGOProtos", dirSourceCopy + "/POGOProtos.NetStandard1");
});
Task("Version").Does(() =>
{
// Read version
var version = System.IO.File.ReadAllText(dirProtos + "/.current-version");
// Fix version
version = System.Text.RegularExpressions.Regex.Replace(version, @"\s+", string.Empty);
// Apply version
var projectFile = dirSourceCopy + "/POGOProtos.NetStandard1/POGOProtos.NetStandard1.csproj";
var updatedProjectFile = System.IO.File
.ReadAllText(projectFile)
.Replace("<Version>1.0.0-rc</Version>", "<Version>" + version + "</Version>");
System.IO.File.WriteAllText(projectFile, updatedProjectFile);
Information("Applied version '" + version + "' to '" + projectFile + "'.");
});
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Copy")
.IsDependentOn("POGOProtos-Tools")
.IsDependentOn("POGOProtos-Clone")
.IsDependentOn("POGOProtos-Compile")
.IsDependentOn("POGOProtos-Move")
.IsDependentOn("Version")
.Does(() =>
{
DotNetCoreRestore(dirSourceCopy + "/POGOProtos.NetStandard1");
DotNetCorePack(dirSourceCopy + "/POGOProtos.NetStandard1", new DotNetCorePackSettings {
Configuration = "Release"
});
});
RunTarget("Default");