forked from nunit/nunit.xamarin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.cake
More file actions
131 lines (111 loc) · 3.84 KB
/
build.cake
File metadata and controls
131 lines (111 loc) · 3.84 KB
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
129
130
131
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Get whether or not this is a local build.
var local = BuildSystem.IsLocalBuild;
var isRunningOnUnix = IsRunningOnUnix();
var isRunningOnWindows = IsRunningOnWindows();
var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
// Versioning
var packageVersion = "3.0.1";
var packageModifier = "";
var displayVersion = "3.0.1";
var semVersion = packageVersion + packageModifier;
// Directories
var basePath = Directory(".");
var outputDirectory = basePath + Directory("bin") + Directory(configuration);
var androidDirectory = basePath + Directory("src/runner/nunit.runner.Droid/bin") + Directory(configuration);
var iosDirectory = basePath + Directory("src/runner/nunit.runner.iOS/bin/AnyCPU") + Directory(configuration);
var wp81Directory = basePath + Directory("src/runner/nunit.runner.wp81/bin") + Directory(configuration);
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(() =>
{
Information("Building version {0} of Nunit.Xamarin.", semVersion);
});
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.WithCriteria(() => isRunningOnWindows)
.Does(() =>
{
CleanDirectories(new DirectoryPath[] {
outputDirectory, androidDirectory, iosDirectory, wp81Directory});
});
Task("Restore-NuGet-Packages")
.Does(() =>
{
NuGetRestore("./nunit.runner.sln", new NuGetRestoreSettings {
Source = new List<string> {
"https://www.nuget.org/api/v2/",
"https://www.myget.org/F/nunit/api/v2"
}
});
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
if(isRunningOnUnix)
{
XBuild("./nunit.runner.sln", new XBuildSettings()
.SetConfiguration("Debug")
.WithTarget("AnyCPU")
.WithProperty("TreatWarningsAsErrors", "true")
.SetVerbosity(Verbosity.Minimal)
);
}
else
{
MSBuild("./nunit.runner.sln", new MSBuildSettings()
.SetConfiguration(configuration)
.SetPlatformTarget(PlatformTarget.MSIL)
.WithProperty("TreatWarningsAsErrors", "true")
.SetVerbosity(Verbosity.Minimal)
.SetNodeReuse(false)
);
}
});
Task("Create-NuGet-Packages")
.IsDependentOn("Build")
.Does(() =>
{
NuGetPack("nuget/nunit.runners.xamarin.nuspec", new NuGetPackSettings
{
Version = semVersion,
BasePath = basePath,
OutputDirectory = outputDirectory,
});
});
Task("Publish-NuGet")
.IsDependentOn("Create-NuGet-Packages")
.WithCriteria(() => local)
.Does(() =>
{
// Resolve the API key.
var apiKey = EnvironmentVariable("NUGET_API_KEY");
if(string.IsNullOrEmpty(apiKey)) {
throw new InvalidOperationException("Could not resolve NuGet API key.");
}
// Get the path to the package.
var packagePath = outputDirectory + File(string.Concat("nunit.runner.xamarin.", semVersion, ".nupkg"));
// Push the package.
NuGetPush(packagePath, new NuGetPushSettings {
ApiKey = apiKey
});
});
Task("Default")
.IsDependentOn("Build");
Task("Package")
.IsDependentOn("Create-NuGet-Packages");
Task("Publish")
.IsDependentOn("Publish-NuGet");
RunTarget(target);