-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.cake
85 lines (72 loc) · 1.93 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
#tool "nuget:?package=NUnit.Runners&version=2.6.3"
#tool "nuget:?package=GitVersion.CommandLine"
var target = Argument("Target", "Default");
var configuration = Argument("Configuration", "Release");
var buildTarget = configuration == "Release"
? "Clean;Rebuild"
: "Build";
var solutionFile = File("./Source/Consolas.sln");
var bag = new Dictionary<string, string>();
Task("Default")
.IsDependentOn("Test");
Task("NuGetPush")
.IsDependentOn("GetVersion")
.IsDependentOn("NuGetPack")
.Does(() =>
{
NuGetPush(GetFiles("./NuGet/Consolas." + bag["NuGetVersion"] + ".nupkg"),
new NuGetPushSettings {
Source = "https://www.nuget.org/api/v2/package"
});
});
Task("NuGetPack")
.IsDependentOn("Copy")
.IsDependentOn("GetVersion")
.Does(() =>
{
var nuGetPackSettings = new NuGetPackSettings {
Version = bag["NuGetVersion"],
OutputDirectory = "./NuGet"
};
NuGetPack("./NuGet/Consolas/Consolas.nuspec", nuGetPackSettings);
});
Task("GetVersion")
.Does(() =>
{
var result = GitVersion();
bag["NuGetVersion"] = result.NuGetVersion;
Information("Version: " + bag["NuGetVersion"]);
});
Task("Copy")
.IsDependentOn("Test")
.Does(() =>
{
if (configuration != "Release")
throw new Exception("Only package with release build!");
var core = Directory("./NuGet/Consolas/lib/net40");
CleanDirectory(core);
CopyFiles(
GetFiles("./Source/ConsoleApp.Core/bin/" + configuration + "/Consolas.Core.*"),
core);
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
var testDlls = GetFiles("./**/UnitTests/**/bin/" + configuration + "/*.Tests.dll");
NUnit(testDlls);
});
Task("Build")
.IsDependentOn("NuGetRestore")
.Does(() =>
{
MSBuild(solutionFile, config => config
.SetConfiguration(configuration)
.WithTarget(buildTarget));
});
Task("NuGetRestore")
.Does(() =>
{
NuGetRestore(solutionFile);
});
RunTarget(target);