-
Notifications
You must be signed in to change notification settings - Fork 29
/
build.cake
100 lines (79 loc) · 2.88 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
98
99
100
using System.Text.RegularExpressions;
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var solution = "./Anywhere.ArcGIS.sln";
var version = "2.0.2";
var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var buildDir = Directory("./src/Anywhere.ArcGIS/bin") + Directory(configuration);
var artifactDir = Directory("./artifacts");
var outputDir = artifactDir + Directory("output");
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Build")
.IsDependentOn("Update-Version")
.Does(() =>
{
DotNetCoreBuild(
solution,
new DotNetCoreBuildSettings
{
Configuration = configuration,
ArgumentCustomization = args => args.Append($"/p:CI=true /v:n"),
OutputDirectory = outputDir
});
});
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
CleanDirectory(artifactDir);
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(solution);
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
var projects = GetFiles("./tests/**/*.csproj");
foreach(var project in projects)
{
DotNetCoreTool(
projectPath: project.FullPath,
command: "xunit",
arguments: $"-configuration {configuration} -diagnostics -stoponfail"
);
}
});
Task("Update-Version")
.IsDependentOn("Restore")
.Does(() =>
{
Information("Setting version to " + version + versionSuffix);
var file = GetFiles("./src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj").First();
var project = System.IO.File.ReadAllText(file.FullPath, Encoding.UTF8);
var projectVersion = new Regex(@"<Version>.+<\/Version>");
project = projectVersion.Replace(project, string.Concat("<Version>", version + versionSuffix, "</Version>"));
System.IO.File.WriteAllText(file.FullPath, project, Encoding.UTF8);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Build");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);