-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.cake
93 lines (81 loc) · 2.61 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
// ARGUMENTS
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var skipTests = Argument("SkipTests", false);
var fullSemVer = Argument("fullSemVer", "0.0.1");
var assemblySemVer = Argument("assemblySemVer", "0.0.1");
var informationalVersion = Argument("informationalVersion", "0.0.1");
// Variables
var artifactsDirectory = Directory("./artifacts");
var solutionFile = "./NLog.Targets.GraylogHttp.sln";
var msBuildSettings = new DotNetCoreMSBuildSettings
{
MaxCpuCount = 1
};
msBuildSettings.Properties.Add("PackageVersion", new List<string> { fullSemVer });
msBuildSettings.Properties.Add("Version", new List<string> { assemblySemVer });
msBuildSettings.Properties.Add("FileVersion", new List<string> { assemblySemVer });
msBuildSettings.Properties.Add("AssemblyVersion", new List<string> { assemblySemVer });
msBuildSettings.Properties.Add("AssemblyInformationalVersion", new List<string> { informationalVersion });
// Define directories.
var buildDir = Directory("./build/bin") + Directory(configuration);
Task("Clean")
.Does(() =>
{
CleanDirectory(artifactsDirectory);
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(solutionFile);
});
Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
var path = MakeAbsolute(new DirectoryPath(solutionFile));
DotNetCoreBuild(path.FullPath, new DotNetCoreBuildSettings
{
Configuration = configuration,
NoRestore = true,
DiagnosticOutput = true,
MSBuildSettings = msBuildSettings,
Verbosity = DotNetCoreVerbosity.Minimal
});
});
Task("Test")
.IsDependentOn("Build")
.WithCriteria(!skipTests)
.Does(() =>
{
var path = MakeAbsolute(new DirectoryPath(solutionFile));
DotNetCoreTest(path.FullPath, new DotNetCoreTestSettings
{
Configuration = configuration,
NoBuild = true,
ResultsDirectory = artifactsDirectory,
Logger = "trx;LogFileName=TestResults.xml"
});
});
Task("Pack")
.IsDependentOn("Build")
.Does(() =>
{
var path = MakeAbsolute(new DirectoryPath(solutionFile));
DotNetCorePack(path.FullPath, new DotNetCorePackSettings
{
Configuration = configuration,
NoRestore = true,
NoBuild = true,
OutputDirectory = artifactsDirectory,
MSBuildSettings = msBuildSettings
});
});
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Pack");
RunTarget(target);