forked from fivenine-zurich/UnifiedMaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
executable file
·153 lines (126 loc) · 4.64 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#tool nuget:?package=GitVersion.CommandLine
#tool "nuget:?package=NUnit.ConsoleRunner"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
string nugetVersion = null;
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(Directory("./bin"));
CleanDirectory(Directory("./obj"));
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore("./UnifiedMaps.sln");
});
Task("UpdateAssemblyInfo")
.Does(() =>
{
// Update the CI version
GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = false,
OutputType = GitVersionOutput.BuildServer
});
// Update the assembly versions
var versionInfo = GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true
});
nugetVersion = versionInfo.NuGetVersion;
Information("Version: {0}", versionInfo.FullSemVer);
Information("NuGet Version: {0}", nugetVersion);
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./UnifiedMaps.sln", settings => {
settings.SetConfiguration(configuration);
settings.MSBuildPlatform = Cake.Common.Tools.MSBuild.MSBuildPlatform.x86;
});
}
else
{
// Use XBuild
XBuild("./UnifiedMaps.sln", settings =>
settings.SetConfiguration(configuration));
}
});
Task("Run-Unit-Tests")
.Does(() =>
{
NUnit3("./bin/Tests/*.Tests.dll", new NUnit3Settings {
NoResults = true
});
});
Task("NuGet-Pack")
.Does( () =>
{
Func<string,string> replacer = (s) => s;
if (IsRunningOnWindows()) {
replacer = (s) => s.Replace("/", @"\");
}
var nuGetPackSettings = new NuGetPackSettings {
Id = "UnifiedMaps",
Version = nugetVersion,
Copyright = "fivenine GmbH " + DateTime.Now.Year,
BasePath = "./bin",
Files = new [] {
// netstandard2.0
new NuSpecContent {Source = replacer("pcl/netstandard2.0/UnifiedMap.dll"), Target = replacer("lib/netstandard2.0/")},
new NuSpecContent {Source = replacer("pcl/netstandard2.0/UnifiedMap.xml"), Target = replacer("lib/netstandard2.0/")},
// Xamarin.iOS Unified API
new NuSpecContent {Source = replacer("Xamarin.iOS10/UnifiedMap*.dll"), Target = replacer("lib/Xamarin.iOS10/")},
new NuSpecContent {Source = replacer("Xamarin.iOS10/UnifiedMap*.xml"), Target = replacer("lib/Xamarin.iOS10/")},
// Xamarin.Mac Unified API
new NuSpecContent {Source = replacer("Xamarin.iOS10/UnifiedMap*.dll"), Target = replacer("lib/Xamarin.Mac20/")},
new NuSpecContent {Source = replacer("Xamarin.iOS10/UnifiedMap*.xml"), Target = replacer("lib/Xamarin.Mac20/")},
// Xamarin Android
new NuSpecContent {Source = replacer("monoandroid/UnifiedMap*.dll"), Target = replacer("lib/MonoAndroid10/")},
new NuSpecContent {Source = replacer("monoandroid/UnifiedMap*.xml"), Target = replacer("lib/MonoAndroid10/")},
}
};
NuGetPack("./UnifiedMaps.nuspec", nuGetPackSettings);
if (AppVeyor.IsRunningOnAppVeyor)
{
foreach (var file in GetFiles("UnifiedMaps*.nupkg"))
AppVeyor.UploadArtifact(file.FullPath);
}
});
Task("NuGet-Publish")
.Does( () =>
{
NuGetPush(GetFiles("UnifiedMaps*.nupkg").First(), new NuGetPushSettings {
Source = "https://www.nuget.org/api/v2/package",
ApiKey = EnvironmentVariable("NUGET_API_KEY")
});
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Build");
Task("Build-CI")
.IsDependentOn("UpdateAssemblyInfo")
.IsDependentOn("Build");
Task("Build-CI-AppVeyor")
.IsDependentOn("UpdateAssemblyInfo")
.IsDependentOn("Build")
.IsDependentOn("NuGet-Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);