-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
72 lines (58 loc) · 2.21 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
#tool "dotnet:?package=GitVersion.Tool&version=5.12.0"
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
const string SOLUTION_FILE = "./ServiceControlExporter.sln";
GitVersion versionInfo;
Task("Version")
.Description("Retrieves the current version from the git repository")
.Does(() => {
versionInfo = GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = false
});
Information($"Version: {versionInfo.SemVer}");
var envFile = EnvironmentVariable("GITHUB_OUTPUT");
Information($"GITHUB_OUTPUT file: {envFile}");
if (!string.IsNullOrEmpty(envFile))
{
Information("Writing version to output.");
System.IO.File.AppendAllText(envFile, $"version={versionInfo.SemVer}\r\n");
}
});
Task("Clean")
.Description("Removes the artifact directory")
.Does(() => {
EnsureDirectoryDoesNotExist("./artifacts");
});
Task("Test")
.Description("Executes tests")
.IsDependentOn("Clean")
.IsDependentOn("Version")
.Does(() => {
var dotnetTestSettings = new DotNetTestSettings
{
Configuration = configuration,
};
DotNetTest(SOLUTION_FILE, dotnetTestSettings);
});
Task("Package")
.IsDependentOn("Test")
.Description("Creates packages for the exporter.")
.Does(() => {
var msBuildSettings = new DotNetMSBuildSettings()
{
Version = versionInfo.AssemblySemVer,
InformationalVersion = versionInfo.InformationalVersion
};
var nugetPackageBuildSettings = new DotNetPublishSettings {
Configuration = configuration,
SelfContained = true,
Runtime = "win10-x64",
OutputDirectory = "./artifacts/win/",
MSBuildSettings = msBuildSettings
};
DotNetPublish("./src/service-control-exporter/service-control-exporter.csproj", nugetPackageBuildSettings);
Zip("./artifacts/win/", $"./artifacts/service-control-exporter.{versionInfo.SemVer}.zip");
});
Task("Default")
.IsDependentOn("Package");
RunTarget(target);