-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.cake
More file actions
110 lines (91 loc) · 3.02 KB
/
build.cake
File metadata and controls
110 lines (91 loc) · 3.02 KB
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
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
string semVer = Argument("semver", "0.0.0");
///////////////////////////////////////////////////////////////////////////////
// VARIABLES
///////////////////////////////////////////////////////////////////////////////
var srcDirectory = "./src";
var distDirectory = "./dist";
var solutionFile = "./src/Nullforce.Api.DeviantArt.Rest.sln";
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(ctx =>
{
// Executed BEFORE the first task.
Information("Running tasks...");
});
Teardown(ctx =>
{
// Executed AFTER the last task.
Information("Finished running tasks.");
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("GetVersionInfo")
.Does(() => {
if (semVer == "0.0.0" && DirectoryExists("./.git"))
{
var result = GitVersion();
Information($"Branch: {result.BranchName}");
Information($"Assembly File Version: {result.AssemblySemFileVer}");
Information($"Assembly Version: {result.AssemblySemFileVer}");
Information($"Full Sem Version: {result.FullSemVer}");
Information($"Legacy Sem Version: {result.LegacySemVer}");
Information($"Legacy Sem Version Padded: {result.LegacySemVerPadded}");
Information($"Major Minor Patch: {result.MajorMinorPatch}");
Information($"Sem Ver: {result.SemVer}");
semVer = result.LegacySemVerPadded;
}
Information($"Using '{semVer}' as the version.");
});
Task("CleanStep")
.Does(() => {
CleanDirectory(distDirectory);
});
Task("RestoreStep")
.Does(() =>
{
DotNetCoreRestore(solutionFile);
});
Task("BuildStep")
.Does(() => {
DotNetCoreBuild(solutionFile);
});
Task("TestStep")
.Does(() => {
var testProjects = GetFiles("./src/**/*.Tests.csproj");
foreach (var testProject in testProjects)
{
DotNetCoreTest(testProject.FullPath);
}
});
Task("PackageStep")
.Does(() => {
var settings = new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = distDirectory,
ArgumentCustomization = (args) => {
return args
.Append("/p:Version={0}", semVer);
}
};
DotNetCorePack("./src/Nullforce.Api.DeviantArt.Rest/Nullforce.Api.DeviantArt.Rest.csproj", settings);
});
Task("Default")
.IsDependentOn("CleanStep")
.IsDependentOn("RestoreStep")
.IsDependentOn("GetVersionInfo")
.IsDependentOn("BuildStep")
.IsDependentOn("TestStep")
.IsDependentOn("PackageStep")
.Does(() => {
Information("Hello Cake!");
});
RunTarget(target);