-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
90 lines (80 loc) · 2.13 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
public record BuildData(
DirectoryPath SourcePath,
DirectoryPath ArtifactsPath,
string Configuration
)
{
public DotNetMSBuildSettings MSBuildSettings { get; } =
new DotNetMSBuildSettings {
Version = "2022.5.19.1"
}
.SetConfiguration(Configuration);
}
Setup(
ctx => new BuildData(
"./src",
"./artifacts",
"Release"
)
);
Task("Clean")
.Does<BuildData>((context,data)=>{
CleanDirectory(data.ArtifactsPath);
});
Task("Restore")
.IsDependentOn("Clean")
.Does<BuildData>((context,data)=>{
DotNetRestore(
data.SourcePath.FullPath,
new DotNetRestoreSettings {
MSBuildSettings = data.MSBuildSettings
}
);
});
Task("Build")
.IsDependentOn("Restore")
.Does<BuildData>((context,data)=>{
DotNetBuild(
data.SourcePath.FullPath,
new DotNetBuildSettings {
NoRestore = true,
MSBuildSettings = data.MSBuildSettings
}
);
});
Task("Test")
.IsDependentOn("Build")
.Does<BuildData>((context,data)=>{
DotNetTest(
data.SourcePath.FullPath,
new DotNetTestSettings {
NoRestore = true,
NoBuild = true,
Configuration = data.Configuration
}
);
});
Task("Package")
.IsDependentOn("Test")
.Does<BuildData>((context,data)=>{
DotNetPack(
data.SourcePath.FullPath,
new DotNetPackSettings {
NoRestore = true,
NoBuild = true,
OutputDirectory = data.ArtifactsPath,
MSBuildSettings = data.MSBuildSettings
}
);
});
Task("Publish")
.IsDependentOn("Package")
.Does<BuildData>(async (context,data)=>{
await GitHubActions.Commands.UploadArtifact(
data.ArtifactsPath,
$"NuGet{Context.Environment.Platform.Family}"
);
});
Task("GitHubActions")
.IsDependentOn("Publish");
RunTarget(Argument("target", "Package"));