-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.cake
79 lines (65 loc) · 1.74 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
var target = Argument("target", "Test");
var configuration = Argument("configuration", "Release");
var version = Argument("package-version", "");
var solution = "./Source/MovieCollection.OpenMovieDatabase.sln";
var artifacts = "./.artifacts";
Task("Clean")
.Does(() =>
{
CleanDirectory(artifacts);
CleanDirectory($"./Source/MovieCollection.OpenMovieDatabase/bin/{configuration}");
});
Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetBuild(solution, new DotNetBuildSettings
{
NoIncremental = true,
Configuration = configuration,
});
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
DotNetTest(solution, new DotNetTestSettings
{
NoBuild = true,
Configuration = configuration,
});
});
Task("Pack")
.IsDependentOn("Test")
.Does(context =>
{
var apiKey = context.EnvironmentVariable("NUGET_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
{
throw new CakeException("No NuGet API key specified.");
}
if (string.IsNullOrWhiteSpace(version))
{
throw new CakeException("No package version specified.");
}
string actualVersion = version;
if (version.StartsWith("v"))
{
actualVersion = version.Substring(1);
}
DotNetPack(solution, new DotNetPackSettings
{
NoRestore = true,
OutputDirectory = artifacts,
Configuration = configuration,
MSBuildSettings = new DotNetMSBuildSettings()
.WithProperty("Version", actualVersion)
});
var files = GetFiles($"{artifacts}/*.nupkg");
context.NuGetPush(files, new NuGetPushSettings
{
ApiKey = apiKey,
Source = "https://api.nuget.org/v3/index.json",
});
});
RunTarget(target);