This repository has been archived by the owner on Nov 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.cake
133 lines (116 loc) · 3.67 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/// <summary>
/// Just a simple build script.
/// </summary>
// Install tools
#tool "nuget:?package=GitVersion.CommandLine"
// *********************
// ARGUMENTS
// *********************
var Target = Argument("target", "default");
var Configuration = Argument("configuration", "Release");
// *********************
// VARIABLES
// *********************
var Solution = File("engenious.sln");
var BuildVerbosity = Verbosity.Minimal;
CreateDirectory(Directory("./logs"));
var Version = GitVersion(new GitVersionSettings {LogFilePath = new FilePath("./logs/gitver.log")});
var IsPrerelease = !(Version.BranchName.ToLower() == "master");
string GetNugetVersion()
{
var version = IsPrerelease ? Version.NuGetVersion : Version.MajorMinorPatch;
if (IsPrerelease && !(version.EndsWith("rc") || version.EndsWith("alpha") || version.EndsWith("beta")))
return version + "-alpha";//TODO: perhaps not everything is Alpha?
return version;
}
// *********************
// SETUP
// *********************
Setup(context =>
{
Information("Building version {0} of engenious.", Version.InformationalVersion);
});
// *********************
// TASKS
// *********************
/// <summary>
/// Task to build the solution. Using MSBuild on Windows and MDToolBuild on OSX / Linux
/// </summary>
Task("build")
.IsDependentOn("patch-version")
.Does(() =>
{
MSBuild(Solution, cfg =>
{
cfg.Configuration = Configuration;
cfg.Verbosity = BuildVerbosity;
});
});
/// <summary>
/// Task to clean all obj and bin directories as well as the ./output folder.
/// Commonly called right before build.
/// </summary>
Task("clean")
.Does(() =>
{
CleanDirectories("./output");
CleanDirectories("./bin");
CleanDirectories(string.Format("./src/**/obj/{0}", Configuration));
});
/// <summary>
/// The default task with a predefined flow.
/// </summary>
Task("default")
.IsDependentOn("clean")
.IsDependentOn("restore")
.IsDependentOn("build")
.IsDependentOn("pack");
/// <summary>
/// Task to bundle build results into a NuGet package.
/// </summary>
Task("pack")
.Does(() =>
{
var artifacts = Directory("./output/artifacts");
CreateDirectory(artifacts);
NuGetPack("./engenious.ci.nuspec", new NuGetPackSettings
{
Version = GetNugetVersion(),
OutputDirectory = artifacts
});
});
/// <summary>
/// Task to patch the current version into the assembly infos
/// </summary>
Task("patch-version")
.Does(() =>
{
// TODO: modify solution to use a shared assembly info
//Information("Skipped due to: Modify solution to use a shared assembly info");
//return;
// Patch assembly info
var solutionInfoFile = "./SolutionInfo.cs";
CreateAssemblyInfo(solutionInfoFile, new AssemblyInfoSettings
{
Product = "engenious",
Company = "jvbsl",
Configuration = Configuration,
Version = Version.AssemblySemVer,
FileVersion = string.Format("{0}.{1}.0", Version.Major, Version.Minor),
InformationalVersion = Version.InformationalVersion,
Copyright = "Copyright (c) jvbsl 2016"
});
});
/// <summary>
/// Task to rebuild. Nothing else than a clean followed by build.
/// </summary>
Task("rebuild")
.IsDependentOn("clean")
.IsDependentOn("build");
/// <summary>
/// Task to restore NuGet packages on solution level for all containing projects.
/// </summary>
Task("restore")
.Does(() => NuGetRestore(Solution));
// Execution
RunTarget(Target);