-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.cake
82 lines (70 loc) · 2.15 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
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var packageOutputDirectory = Argument("packageOutputDirectory", "dist");
readonly FilePath solutionFile = "src/Cake.Wget.sln";
readonly FilePath projectFile = "src/Cake.Wget/Cake.Wget.csproj";
readonly FilePath testProjectFile = "src/Cake.Wget.Tests/Cake.Wget.Tests.csproj";
readonly FilePath testReportDirectory = "TestsOutput";
readonly FilePath testReport = $"{testReportDirectory}/report.trx";
readonly FilePath coverageReportDirectory = "CoverageResults";
readonly FilePath coverageReport = $"{coverageReportDirectory}/coverage.xml";
readonly string framework = "net9.0";
Task("Clean")
.Does(() =>
{
CleanDirectory(packageOutputDirectory);
CleanDirectory(testReportDirectory.FullPath);
CleanDirectory(coverageReportDirectory.FullPath);
CleanDirectories("**/bin");
CleanDirectories("**/obj");
});
Task("Restore-Packages")
.Does(() =>
{
DotNetRestore(solutionFile.FullPath);
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore-Packages")
.Does(() =>
{
var settings = new DotNetBuildSettings
{
Configuration = configuration,
Framework = framework,
};
DotNetBuild(projectFile.FullPath, settings);
});
Task("Test")
.IsDependentOn("Clean")
.IsDependentOn("Restore-Packages")
.Does(() =>
{
var settings = new DotNetTestSettings
{
Configuration = configuration,
Framework = framework,
Loggers = new List<string>() {"trx"},
VSTestReportPath = testReport.FullPath,
};
settings.ArgumentCustomization =
args => args.Append("/p:CollectCoverage=true")
.Append($"/p:CoverletOutput=../../{coverageReport}")
.Append("/p:CoverletOutputFormat=opencover")
.Append("/p:Exclude=[xunit.*]*");
DotNetTest(testProjectFile.FullPath, settings);
});
Task("Package")
.IsDependentOn("Test")
.Does(() =>
{
var settings = new DotNetPackSettings
{
OutputDirectory = packageOutputDirectory,
Configuration = configuration,
};
DotNetPack(projectFile.FullPath, settings);
});
Task("Default")
.IsDependentOn("Test");
RunTarget(target);