-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
117 lines (94 loc) · 3.14 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
108
109
110
111
112
113
114
115
116
117
#tool "nuget:?package=GitVersion.CommandLine"
#addin nuget:?package=Cake.Git
#addin "Cake.Incubator"
var target = Argument<string>("target", "Default");
GitVersion result;
DotNetCoreMSBuildSettings MSBuildSettings;
string SolutionLocation = "./src/MQTTServer.sln";
string PackagesLocation = "./packages.local";
Setup((c) =>
{
});
Teardown((c) =>
{
// Executed AFTER the last task.
Information("Finished running tasks.");
});
Task("Update-Version")
.Does(() => {
Information("Calculating Semantic Version...");
var fullBranchName = "refs/"+GitDescribe(".", false, GitDescribeStrategy.All);
Environment.SetEnvironmentVariable("Git_Branch", fullBranchName, EnvironmentVariableTarget.Process);
result = GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.Json,
Branch = fullBranchName,
NoFetch = true
});
var cakeVersion = typeof(ICakeContext).Assembly.GetName().Version.ToString();
MSBuildSettings = new DotNetCoreMSBuildSettings()
.WithProperty("Version", result.LegacySemVerPadded)
.WithProperty("AssemblyVersion", result.MajorMinorPatch)
.WithProperty("FileVersion", result.MajorMinorPatch)
.WithProperty("AssemblyInformationalVersion", result.InformationalVersion);
Information($"Cake Version : {cakeVersion}");
Information("");
Information("GitVersion:");
Information(result.Dump());
});
Task("Clean-Packages-Local")
.Does(() => {
CleanDirectories(PackagesLocation);
});
Task("Restore")
.Does(() => {
DotNetCoreRestore(SolutionLocation);
});
Task("Build")
.IsDependentOn("Restore")
.IsDependentOn("Update-Version")
.Does(() => {
DotNetCoreBuild(SolutionLocation, new DotNetCoreBuildSettings {
Configuration = "Release",
MSBuildSettings = MSBuildSettings
});
});
Task("Publish")
.IsDependentOn("Build")
.Does(() => {
DotNetCorePublish(SolutionLocation, new DotNetCorePublishSettings {
Configuration = "Release",
MSBuildSettings = MSBuildSettings
});
});
Task("Pack")
.IsDependentOn("Clean-Packages-Local")
.IsDependentOn("Publish")
.Does(() => {
DotNetCorePack(SolutionLocation, new DotNetCorePackSettings {
NoBuild = true,
Configuration = "Release",
OutputDirectory = PackagesLocation,
MSBuildSettings = MSBuildSettings
});
});
Task("Push")
.IsDependentOn("Pack")
.Does(() => {
foreach(var nupkgFile in GetFiles(PackagesLocation+"/*.nupkg"))
{
Information($"Pushing Package {nupkgFile}");
NuGetPush(nupkgFile, new NuGetPushSettings {
Source = "https://api.nuget.org/v3/index.json"
});
Information($"Succesfully Pushed Package {nupkgFile}");
}
})
.OnError((e) => {
Error(e.ToString());
});
Task("Default")
.IsDependentOn("Build");
Task("Deploy")
.IsDependentOn("Push");
RunTarget(target);