-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.cake
94 lines (75 loc) · 2.11 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
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
#tool "nuget:?package=xunit.runner.console"
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
// Define directories.
var buildDir = Directory("./YahooFinance.NET/bin") + Directory(configuration);
var buildTestDir = Directory("./YahooFinance.NET.Tests/bin") + Directory(configuration);
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
CleanDirectory(buildTestDir);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore("./YahooFinance.NET.sln");
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
MSBuild("./YahooFinance.NET.sln", settings =>
settings.SetConfiguration(configuration));
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
XUnit2(buildTestDir.ToString() + "/*.Tests.dll");
});
Task("CleanupOldNugetPackages")
.Does(() =>
{
var oldPackages = GetFiles("YahooFinance.NET*.nupkg");
foreach(var file in oldPackages)
{
DeleteFile(file);
}
});
Task("CreateNugetPackage")
.IsDependentOn("Test")
.IsDependentOn("CleanupOldNugetPackages")
.Does(() =>
{
var projectFile = new FilePath(@"YahooFinance.NET\YahooFinance.NET.csproj");
var nuGetPackSettings = new NuGetPackSettings {
Symbols = false,
Properties = new Dictionary<string, string>
{
{ "Configuration", configuration },
}
};
NuGetPack(projectFile, nuGetPackSettings);
});
Task("Deploy")
.IsDependentOn("CreateNugetPackage")
.Does(() =>
{
var packages = GetFiles("YahooFinance.NET*.nupkg");
Information("Deploying the following files...");
foreach(var file in packages)
{
Information("File: {0}", file);
}
//This will fail unless the NuGet API Key is set
//nuget.exe setApiKey <API-Key> -Source https://www.nuget.org/api/v2/package
NuGetPush(packages, new NuGetPushSettings {
Source = "https://www.nuget.org/api/v2/package",
});
});
Task("Default")
.IsDependentOn("Test");
RunTarget(target);