-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.cake
89 lines (79 loc) · 3.24 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
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var pullrequest = Argument("pullrequest", 0);
var prerelease = Argument("prerelease", true) || pullrequest > 0;
// a bit of logic to create the version number:
// - input = 1.2.3.4
// - package version = 1.2.3
// - preview package version = 1.2.3-preview.4
var version = Version.Parse(Argument("packageversion", "1.0.0.0"));
var previewNumber = version.Revision;
var assemblyVersion = $"{version.Major}.0.0.0";
var fileVersion = $"{version.Major}.{version.Minor}.{version.Build}.0";
var infoVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
var packageVersion = $"{version.Major}.{version.Minor}.{version.Build}";
var previewlabel = pullrequest > 0 ? $"pr.{pullrequest}" : "preview";
var previewVersion = $"{packageVersion}-{previewlabel}.{previewNumber}";
var finalBuildNumber = prerelease ? previewVersion : packageVersion;
Information("Build configuration: {0}", configuration);
Information("Input version number: {0}", version);
Information("Package version number: {0}", finalBuildNumber);
Information($"##vso[build.updatebuildnumber]{finalBuildNumber}");
Task("Build")
.Does(() =>
{
var msbuildSettings = new DotNetMSBuildSettings()
.SetConfiguration(configuration)
.WithProperty("Version", assemblyVersion)
.WithProperty("FileVersion", fileVersion)
.WithProperty("InformationalVersion", infoVersion);
var settings = new DotNetBuildSettings
{
MSBuildSettings = msbuildSettings
};
DotNetBuild("Mono.ApiTools.sln", settings);
});
Task("Pack")
.Does(() =>
{
var msbuildSettings = new DotNetMSBuildSettings()
.SetConfiguration(configuration)
.WithProperty("Version", assemblyVersion)
.WithProperty("FileVersion", fileVersion)
.WithProperty("InformationalVersion", infoVersion)
.WithProperty("PackageOutputPath", MakeAbsolute((DirectoryPath)"./output/").FullPath)
.WithProperty("PackageVersion", prerelease ? previewVersion : packageVersion)
.WithTarget("Pack");
var settings = new DotNetBuildSettings
{
MSBuildSettings = msbuildSettings
};
DotNetBuild("Mono.ApiTools.slnf", settings);
});
Task("Test")
.IsDependentOn("Build")
.IsDependentOn("Pack")
.Does(() =>
{
Information("Running unit tests...");
var msbuildSettings = new DotNetMSBuildSettings()
.SetConfiguration(configuration)
.WithProperty("Version", assemblyVersion)
.WithProperty("FileVersion", fileVersion)
.WithProperty("InformationalVersion", infoVersion);
DotNetTest("Mono.ApiTools.sln", new DotNetTestSettings
{
MSBuildSettings = msbuildSettings,
Loggers = new [] { "trx" }
});
Information("Running app tests...");
var app = $"api-tools/bin/{configuration}/net8.0/api-tools.dll";
var id = "Mono.ApiTools.NuGetDiff";
var version = prerelease ? previewVersion : packageVersion;
DotNetExecute(app, $"nuget-diff ./output/{id}.{version}.nupkg --latest --cache=externals --output=diff");
});
Task("Default")
.IsDependentOn("Pack")
.IsDependentOn("Build")
.IsDependentOn("Test");
RunTarget(target);