-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.cake
84 lines (76 loc) · 1.85 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
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.9.0"
#addin "nuget:?package=Cake.DoInDirectory&version=3.3.0"
var target = Argument("target", "Build");
var configuration = Argument("buildConfiguration", "Debug");
var packageVersion = Argument("buildVersion", "8.8.8");
var apiKey = Argument("nugetKey", "");
Task("Clean")
.Does(() =>
{
CleanDirectory("Cake.XComponent/bin");
CleanDirectory("Cake.XComponent/obj");
CleanDirectory("Cake.XComponent.Test/bin");
CleanDirectory("Cake.XComponent.Test/obj");
});
Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore("Cake.XComponent.sln");
DotNetCoreBuild(
"Cake.XComponent.sln",
new DotNetCoreBuildSettings {
Configuration = configuration,
VersionSuffix = packageVersion,
MSBuildSettings = new DotNetCoreMSBuildSettings{}.SetVersion(packageVersion),
}
);
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
var projectFiles = GetFiles("./**/*Test.csproj");
foreach(var file in projectFiles)
{
DotNetCoreTest(file.FullPath);
}
});
Task("Package")
.IsDependentOn("Test")
.Does(() =>
{
DotNetCorePack(
"Cake.XComponent/Cake.XComponent.csproj",
new DotNetCorePackSettings {
Configuration = configuration,
IncludeSymbols = true,
NoBuild = true,
OutputDirectory = @"nuget",
VersionSuffix = packageVersion,
MSBuildSettings = new DotNetCoreMSBuildSettings{}.SetVersion(packageVersion),
}
);
});
Task("Deploy")
.IsDependentOn("Package")
.Does(() =>
{
if (!string.IsNullOrEmpty(apiKey))
{
DoInDirectory("./nuget", () =>
{
var package = "Cake.XComponent." + packageVersion + ".nupkg";
DotNetCoreNuGetPush(package, new DotNetCoreNuGetPushSettings
{
Source = "https://api.nuget.org/v3/index.json",
ApiKey = apiKey
});
});
}
else
{
Error("No Api Key provided. Can't deploy package to Nuget.");
}
});
RunTarget(target);