-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.cake
129 lines (105 loc) · 3.43 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
124
125
126
127
128
129
#tool "dotnet:?package=GitVersion.Tool&version=5.12.0"
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
///////////////////////////////////////////////////////////////////////////////
// Setup
///////////////////////////////////////////////////////////////////////////////
string solution = "CakeExt.sln";
GitVersion version;
string buildId;
var dotNetVerbosity = DotNetVerbosity.Minimal;
var msBuildSettings = new DotNetMSBuildSettings()
.SetMaxCpuCount(0);
Setup(context =>
{
if (context == null)
Error("Context null");
version = context.GitVersion();
if (version == null)
Error("Could not determine version from GitVersion.");
Information($"Solution: {solution}");
Information($"Version: {version.FullSemVer}");
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("CleanArtifacts")
.Does(() =>
{
CleanDirectory("./artifacts");
CreateDirectory("./artifacts/nuget");
});
Task("Clean")
.WithCriteria(c => HasArgument("rebuild"))
.Does(() =>
{
var objs = GetDirectories($"./**/obj");
var bins = GetDirectories($"./**/bin");
CleanDirectories(objs.Concat(bins));
});
Task("RestorePackages")
.Does(() =>
{
DotNetRestore(new DotNetRestoreSettings
{
Verbosity = dotNetVerbosity,
MSBuildSettings = msBuildSettings,
});
});
Task("Compile")
.IsDependentOn("RestorePackages")
.Does(() =>
{
var buildSettings = new DotNetBuildSettings
{
Configuration = configuration,
NoRestore = true,
Verbosity = dotNetVerbosity,
MSBuildSettings = msBuildSettings,
};
DotNetBuild(solution, buildSettings);
});
Task("Publish")
.IsDependentOn("Compile")
.Does(() => {
// Get all projects that have a Dockerfile in the same directory.
var projectFiles = GetFiles("**/*Cake*.csproj");
foreach(var project in projectFiles)
{
Information($"Publish {project}...");
var publishDirectory = $"./artifacts/{project.GetFilenameWithoutExtension()}";
DotNetPublish(
project.FullPath,
new DotNetPublishSettings
{
Configuration = configuration,
NoRestore = true,
NoBuild = true,
Verbosity = dotNetVerbosity,
MSBuildSettings = msBuildSettings,
OutputDirectory = publishDirectory
}
);
DotNetPack(
project.FullPath,
new DotNetPackSettings
{
Configuration = configuration,
NoRestore = true,
NoBuild = true,
Verbosity = dotNetVerbosity,
MSBuildSettings = msBuildSettings,
OutputDirectory = "./artifacts/nuget",
IncludeSymbols = false
}
);
}
});
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("CleanArtifacts")
.IsDependentOn("Publish");
RunTarget(target);