-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
123 lines (107 loc) · 3.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#addin "nuget:?package=Cake.Services&version=0.2.9"
#addin "nuget:?package=Cake.Http&version=0.3.0"
#addin "nuget:?package=Cake.Powershell&version=0.3.5"
#addin "nuget:?package=Cake.Git&version=0.15.0"
#addin "Newtonsoft.Json"
#tool "nuget:?package=xunit.runner.console&version=2.2.0"
#tool "nuget:?package=OctopusTools&version=4.22.1"
#tool "nuget:?package=iisexpress.runner.service&version=0.1.5"
#tool "nuget:?package=SpecRun.Runner&version=1.6.0"
#tool "nuget:?package=NuGet.CommandLine&version=4.3.0"
/////////////////////////////////
// ARGUMENTS
/////////////////////////////////
var target = Argument<string>("target", "Default");
var configuration = Argument<string>("configuration", "Debug");
/////////////////////////////////
//VARIABLES
/////////////////////////////////
var solutions = GetFiles("./**/*.sln");
var solutionPaths = solutions.Select(solution => solution.GetDirectory());
/////////////////////////////
// TASKS
/////////////////////////////
Task("Clean")
.Description("Cleans all directories that are used during the build process.")
.Does(() =>
{
// Clean solution directories.
foreach(var path in solutionPaths)
{
Information("Cleaning {0}", path);
CleanDirectories(path + "/**/bin/" + configuration);
CleanDirectories(path + "/**/obj/" + configuration);
}
});
Task("Restore")
.Description("Restores all packages that are used by all solutions.")
.Does(() =>
{
foreach(var solution in solutions)
{
Information("Restoring {0}...", solution);
DotNetCoreRestore(solution.ToString());
}
});
Task("Build")
.Description("Builds all the different parts of the project.")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.Does(() =>
{
// Build all solutions.
foreach(var solution in solutions)
{
Information("Building {0}", solution);
DotNetCoreBuild(solution.ToString(), new DotNetCoreBuildSettings()
{
Configuration = configuration
});
}
});
Task("Test")
.IsDependentOn("Test-Unit")
.IsDependentOn("Test-Integration");
Task("Test-Unit")
.Does(() =>
{
var projects = GetFiles("./**/*Test.Unit*.csproj");
foreach(var project in projects)
{
DotNetCoreTest(
project.FullPath,
new DotNetCoreTestSettings()
{
Configuration = "release",
NoBuild = true
});
}
});
Task("Test-Integration")
.Does(() =>
{
var projects = GetFiles("./**/*Test.Integration*.csproj");
foreach(var project in projects)
{
DotNetCoreTest(
project.FullPath,
new DotNetCoreTestSettings()
{
Configuration = "release",
NoBuild = true
});
}
});
Task("Build+Test")
.IsDependentOn("Build")
.IsDependentOn("Test");
///////////////////////////////////////////////////////////////////////////////
// TARGETS
///////////////////////////////////////////////////////////////////////////////
Task("Default")
.Description("Runs Build and Test.")
.IsDependentOn("Build+Test");
///////////////////////////////////////////////////////////////////////////////
// EXECUTION
///////////////////////////////////////////////////////////////////////////////
RunTarget(target);