Repository navigation
Expand file tree
/
Copy pathbuild.cake
More file actions
94 lines (79 loc) · 2.64 KB
/
Copy pathbuild.cake
File metadata and controls
94 lines (79 loc) · 2.64 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
// 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 = new BuildConfig
{
Target = Argument("target", "Default"),
BuildNumber = Argument<int>("buildNumber"),
CurrentRelease = Argument("currentRelease", "1.0.1"),
Branch = Argument<string>("branch"),
BuildPath = Argument<string>("buildPath"),
NuGetApiKey = Argument("nuGetApiKey", ""),
GitHubApiKey = Argument("gitHubApiKey", ""),
Verbose = Argument("verbose", false),
MaxDegreeOfParallelism = Argument("maxDegreeOfParallelism", 5),
CurrentVersion = Argument("currentVersion", "")
};
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 = "net10.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")
.Description("Runs the build");
RunTarget(config.Target);