-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
85 lines (69 loc) · 2.26 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
// Addins
#addin nuget:?package=Cake.ArgumentBinder&version=3.0.0
// Usings
using System.IO;
using System.Threading.Tasks;
// Other includes
#load "./build/BuildConfig.cake";
#load "./build/BuildPaths.cake";
#load "./build/Utilities.cake";
#load "./build/BuildOperations.cake";
#load "./build/TestOperations.cake";
#load "./build/PublishOperations.cake";
// Arguments
var config = CreateFromArguments<BuildConfig>();
if (string.IsNullOrEmpty(config.CurrentVersion)) config.CurrentVersion = GetVersion(config);
Information($"Current Version: {config.CurrentVersion}");
var paths = new BuildPaths(Context, config.BuildPath);
Information($"Build Output Paths\n{paths}");
const string SolutionPath = "./CodePointEnumGenerator.sln";
const string FrameworkVersion = "net6.0";
var testProjects = GetFiles("./**/*Tests.csproj")
.Select(testProject => new TestProject {
FullPath = testProject.FullPath,
FrameworkVersion = FrameworkVersion
})
.ToList();
var msBuildSettings = new DotNetMSBuildSettings()
.SetVersion(config.CurrentVersion)
.WithProperty("FileVersion", config.CurrentVersion)
.WithProperty("InformationalVersion", config.CurrentVersion)
.WithProperty("AssemblyVersion", config.CurrentVersion)
.SetMaxCpuCount(-1);
Task("Clean")
.Does(() =>
{
CleanDirectory(paths.BuildOutput);
DeleteFiles("./**/*.trx");
});
Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
DoBuild(
config,
SolutionPath,
msBuildSettings);
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
CreateDirectory(paths.TestResults);
ParallelInvoke(
testProjects,
testProject => DoTest(
testProject,
paths.TestResults,
config.Verbose),
config.MaxDegreeOfParallelism);
});
Task("Publish")
.IsDependentOn("Test")
.Does(async () => {
await DoPublish(config, paths, msBuildSettings, SolutionPath);
});
Task("Default")
.IsDependentOn("Publish")
.DescriptionFromArguments<BuildConfig>("Runs the build");
RunTarget(config.Target);