This repository has been archived by the owner on Aug 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.cake
128 lines (112 loc) · 3.33 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
#tool nuget:?package=GitVersion.CommandLine&version=4.0.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var nugetApiKey = Argument("nugetapikey", EnvironmentVariable("NUGET_API_KEY"));
//////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
//////////////////////////////////////////////////////////////////////
var version = "0.1.0";
var versionNumber = "0.1.0";
var artifacts = Directory("./artifacts");
var solution = File("./Machine.Specifications.Reporting.sln");
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectories("./src/**/bin");
CleanDirectories("./src/**/obj");
CleanDirectory(artifacts);
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(solution);
});
Task("Versioning")
.IsDependentOn("Clean")
.Does(() =>
{
if (!BuildSystem.IsLocalBuild)
{
GitVersion(new GitVersionSettings
{
OutputType = GitVersionOutput.BuildServer
});
}
var result = GitVersion(new GitVersionSettings
{
OutputType = GitVersionOutput.Json
});
version = result.NuGetVersion;
versionNumber = result.MajorMinorPatch;
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Versioning")
.Does(() =>
{
CreateDirectory(artifacts);
DotNetCoreBuild(solution, new DotNetCoreBuildSettings
{
Configuration = configuration,
ArgumentCustomization = x => x
.Append("/p:Version={0}", version)
.Append("/p:AssemblyVersion={0}", versionNumber)
.Append("/p:FileVersion={0}", versionNumber)
});
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
DotNetCoreTest(solution, new DotNetCoreTestSettings
{
Configuration = configuration,
NoBuild = true
});
});
Task("Package")
.IsDependentOn("Build")
.IsDependentOn("Test")
.Does(() =>
{
DotNetCorePack(solution, new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = artifacts,
NoBuild = true,
ArgumentCustomization = x => x
.Append("/p:Version={0}", version)
});
});
Task("Publish")
.IsDependentOn("Package")
.WithCriteria(() => BuildSystem.IsRunningOnAppVeyor)
.WithCriteria(() => AppVeyor.Environment.Repository.Tag.IsTag)
.Does(() =>
{
var packages = GetFiles("./artifacts/**/*.nupkg");
foreach (var package in packages)
{
DotNetCoreNuGetPush(package.FullPath, new DotNetCoreNuGetPushSettings
{
Source = "https://www.nuget.org/api/v2/package",
ApiKey = nugetApiKey
});
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Publish");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);