-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.cake
107 lines (96 loc) · 3.69 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
#tool nuget:?package=ReportGenerator&version=5.3.0
var target = Argument("Target", "Default");
var configuration =
HasArgument("Configuration") ? Argument<string>("Configuration") :
EnvironmentVariable("Configuration", "Release");
var artifactsDirectory = Directory("./Artifacts");
Task("Clean")
.Description("Cleans the artifacts, bin and obj directories.")
.Does(() =>
{
CleanDirectory(artifactsDirectory);
DeleteDirectories(GetDirectories("**/bin"), new DeleteDirectorySettings() { Force = true, Recursive = true });
DeleteDirectories(GetDirectories("**/obj"), new DeleteDirectorySettings() { Force = true, Recursive = true });
});
Task("Restore")
.Description("Restores NuGet packages.")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetRestore();
});
Task("Build")
.Description("Builds the solution.")
.IsDependentOn("Restore")
.Does(() =>
{
DotNetBuild(
".",
new DotNetBuildSettings()
{
Configuration = configuration,
NoRestore = true,
});
});
Task("Test")
.Description("Runs unit tests and outputs test results to the artifacts directory.")
.DoesForEach(GetFiles("./tests/**/*.Tests.csproj"), project =>
{
Information($"Preparing {project.GetFilename()} for test");
DotNetTest(
project.ToString(),
new DotNetTestSettings()
{
//ArgumentCustomization = args => args.Append($"--diag:{artifactsDirectory}/log.txt"),
Blame = true,
Collectors = new string[] { "XPlat Code Coverage" },
Configuration = configuration,
Framework = "net8.0",
Loggers = new string[]
{
$"trx;LogFileName={project.GetFilenameWithoutExtension()}.trx",
$"html;LogFileName={project.GetFilenameWithoutExtension()}.html",
},
NoBuild = true,
NoRestore = true,
ResultsDirectory = $"{artifactsDirectory}/TestResults",
Settings = "CodeCoverage.runsettings"
});
});
Task("CoverageReport")
.IsDependentOn("Test")
.Does(() =>
{
ReportGenerator(report: $"{artifactsDirectory}/TestResults/**/coverage.cobertura.xml",
targetDir: new DirectoryPath($"{artifactsDirectory}/TestResults/Coverage/Reports"),
settings: new ReportGeneratorSettings
{
ArgumentCustomization = args => args.Append("-reporttypes:HtmlInline;HTMLChart;Cobertura")
});
});
Task("Pack")
.Description("Creates the NuGet packages and outputs them to the artifacts directory.")
.Does(() =>
{
DotNetPack(
"./src/Paseto/",
new DotNetPackSettings()
{
Configuration = configuration,
IncludeSymbols = false,
MSBuildSettings = new DotNetMSBuildSettings()
{
ContinuousIntegrationBuild = !BuildSystem.IsLocalBuild,
},
NoBuild = true,
NoRestore = true,
OutputDirectory = artifactsDirectory,
});
});
Task("Default")
.Description("Cleans, restores NuGet packages, builds the solution, runs unit tests and then create the NuGet packages.")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("CoverageReport")
.IsDependentOn("Pack");
RunTarget(target);