This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathbuild.cake
94 lines (81 loc) · 2.7 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
#tool "nuget:?package=xunit.runner.console"
var config = Argument("configuration", "Release");
var gitHash = Argument("githash", "Unknown Git Hash");
var buildDir = Directory("./Titan/bin/") + Directory(config);
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
if (!NuGetHasSource("https://www.myget.org/F/eto/api/v3/index.json")) {
// First add MyGet Eto source
NuGetAddSource(
name: "MyGet.org Eto",
source: "https://www.myget.org/F/eto/api/v3/index.json"
);
}
NuGetRestore("./Titan.sln");
});
Task("Set-Version-To-Current-Git-Hash")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
Information("Building for Git Hash: " + gitHash);
CopyFile("./Titan/Properties/AssemblyInfo.cs", "./Titan/Properties/AssemblyInfo.cs.old");
CopyFile("./TitanTest/Properties/AssemblyInfo.cs", "./TitanTest/Properties/AssemblyInfo.cs.old");
TransformTextFile("./Titan/Properties/AssemblyInfo.cs")
.WithToken("GitHash", gitHash)
.Save("./Titan/Properties/AssemblyInfo.cs");
TransformTextFile("./TitanTest/Properties/AssemblyInfo.cs")
.WithToken("GitHash", gitHash)
.Save("./TitanTest/Properties/AssemblyInfo.cs");
});
Task("Build")
.IsDependentOn("Set-Version-To-Current-Git-Hash")
.Does(() =>
{
if (IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./Titan.sln", new MSBuildSettings {
Configuration = config,
MSBuildPlatform = MSBuildPlatform.x64,
PlatformTarget = PlatformTarget.x64
});
}
else
{
// Use MSBuild 15 provided by Mono
MSBuild("./Titan.sln", new MSBuildSettings {
Configuration = config,
ToolPath = "/usr/lib/mono/msbuild/15.0/bin/MSBuild.dll",
MSBuildPlatform = MSBuildPlatform.x64,
PlatformTarget = PlatformTarget.x64
});
}
});
Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
XUnit2(GetFiles("./TitanTest/bin/x64/" + config + "/TitanTest.dll"), new XUnit2Settings()
{
Parallelism = ParallelismOption.All,
XmlReport = true,
OutputDirectory = "./TitanTest/bin/x64/" + config + "/results"
});
});
Task("Cleanup")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
{
DeleteFile("./Titan/Properties/AssemblyInfo.cs");
DeleteFile("./TitanTest/Properties/AssemblyInfo.cs");
MoveFile("./Titan/Properties/AssemblyInfo.cs.old", "./Titan/Properties/AssemblyInfo.cs");
MoveFile("./TitanTest/Properties/AssemblyInfo.cs.old", "./TitanTest/Properties/AssemblyInfo.cs");
});
RunTarget("Cleanup");