-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.cake
121 lines (101 loc) · 3.67 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
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument<string>("target", "Default");
var configuration = Argument<string>("configuration", "Release");
var versionNumber = Argument<string>("versionNumber", "0.0.0");
///////////////////////////////////////////////////////////////////////////////
// VARIABLES
///////////////////////////////////////////////////////////////////////////////
var solution = GetFiles("./src/*.sln").First();
var artifactsDir = Directory("./artifacts");
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(_ =>
{
Information("Target {0}", target);
Information("Target {0}", target);
Information("Configuration {0}", configuration);
Information("Version {0}", versionNumber);
});
Teardown(_ =>
{
Information("Finished running tasks");
});
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Build")
;
Task("Build")
.IsDependentOn("Run_dotnet_info")
.IsDependentOn("Clean")
.IsDependentOn("Build_solution")
.IsDependentOn("Run_tests")
.IsDependentOn("Package")
;
Task("Run_dotnet_info")
.Does(() =>
{
Information("dotnet --info");
StartProcess("dotnet", new ProcessSettings { Arguments = "--info" });
});
Task("Clean")
.Does(_ =>
{
Information("Cleaning {0}, bin and obj folders", artifactsDir);
CleanDirectory(artifactsDir);
CleanDirectories("./src/**/bin");
CleanDirectories("./src/**/obj");
});
Task("Build_solution")
.Does(_ =>
{
Information("Building solution {0} v{1}", solution.GetFilenameWithoutExtension(), versionNumber);
DotNetCoreBuild(solution.FullPath, new DotNetCoreBuildSettings()
{
Configuration = configuration,
NoIncremental = true,
MSBuildSettings = new DotNetCoreMSBuildSettings()
.SetVersion(versionNumber)
.SetFileVersion(versionNumber)
// Only including a major version in the AssemblyVersion to reduce binding redirects
// https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/versioning#assembly-version
.WithProperty("AssemblyVersion", $"{Version.Parse(versionNumber).Major}.0.0")
// 0 = use as many processes as there are available CPUs to build the project
// see: https://develop.cakebuild.net/api/Cake.Common.Tools.MSBuild/MSBuildSettings/60E763EA
.SetMaxCpuCount(0)
});
});
Task("Run_tests")
.Does(_ =>
{
Information("Testing solution {0}", solution.GetFilenameWithoutExtension());
DotNetCoreTest(solution.FullPath, new DotNetCoreTestSettings
{
Configuration = configuration,
ResultsDirectory = artifactsDir,
Logger = "trx",
NoBuild = true,
NoRestore = true
});
});
Task("Package")
.Does(_ =>
{
Information("Packaging solution {0}", solution.GetFilenameWithoutExtension());
DotNetCorePack(solution.FullPath, new DotNetCorePackSettings {
Configuration = configuration,
OutputDirectory = artifactsDir,
NoBuild = true,
NoRestore = true,
MSBuildSettings = new DotNetCoreMSBuildSettings()
.SetVersion(versionNumber)
});
});
///////////////////////////////////////////////////////////////////////////////
// EXECUTION
///////////////////////////////////////////////////////////////////////////////
RunTarget(target);