forked from jamesmontemagno/SettingsPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
123 lines (96 loc) · 3.05 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
#addin nuget:https://nuget.org/api/v2/?package=Cake.FileHelpers&version=1.0.3.2
#addin nuget:https://nuget.org/api/v2/?package=Cake.Xamarin&version=1.2.3
var TARGET = Argument ("target", Argument ("t", "Default"));
var version = EnvironmentVariable ("APPVEYOR_BUILD_VERSION") ?? Argument("version", "0.0.9999");
var libraries = new Dictionary<string, string> {
{ "./src/Settings.sln", "Any" },
};
var samples = new Dictionary<string, string> {
{ "./samples/SettingsSample.sln", "Win" },
};
var BuildAction = new Action<Dictionary<string, string>> (solutions =>
{
foreach (var sln in solutions)
{
// If the platform is Any build regardless
// If the platform is Win and we are running on windows build
// If the platform is Mac and we are running on Mac, build
if ((sln.Value == "Any")
|| (sln.Value == "Win" && IsRunningOnWindows ())
|| (sln.Value == "Mac" && IsRunningOnUnix ()))
{
// Bit of a hack to use nuget3 to restore packages for project.json
if (IsRunningOnWindows ())
{
Information ("RunningOn: {0}", "Windows");
NuGetRestore (sln.Key, new NuGetRestoreSettings
{
ToolPath = "./tools/nuget3.exe"
});
// Windows Phone / Universal projects require not using the amd64 msbuild
MSBuild (sln.Key, c =>
{
c.Configuration = "Release";
c.MSBuildPlatform = Cake.Common.Tools.MSBuild.MSBuildPlatform.x86;
});
}
else
{
// Mac is easy ;)
NuGetRestore (sln.Key);
DotNetBuild (sln.Key, c => c.Configuration = "Release");
}
}
}
});
Task("Libraries").Does(()=>
{
BuildAction(libraries);
});
Task("Samples")
.IsDependentOn("Libraries")
.Does(()=>
{
BuildAction(samples);
});
Task ("NuGet")
.IsDependentOn ("Samples")
.Does (() =>
{
if(!DirectoryExists("./Build/nuget/"))
CreateDirectory("./Build/nuget");
NuGetPack ("./nuget/Plugin.nuspec", new NuGetPackSettings {
Version = version,
Verbosity = NuGetVerbosity.Detailed,
OutputDirectory = "./Build/nuget/",
BasePath = "./",
});
});
Task("Component")
.IsDependentOn("Samples")
.IsDependentOn("NuGet")
.Does(()=>
{
if(!version.Contains("beta"))
{
// Clear out xml files from build (they interfere with the component packaging)
DeleteFiles ("./Build/**/*.xml");
// Generate component.yaml files from templates
CopyFile ("./component/component.template.yaml", "./component/component.yaml");
// Replace version in template files
ReplaceTextInFiles ("./**/component.yaml", "{VERSION}", version);
var xamCompSettings = new XamarinComponentSettings { ToolPath = "./tools/xamarin-component.exe" };
// Package both components
PackageComponent ("./component/", xamCompSettings);
}
});
//Build the component, which build samples, nugets, and libraries
Task ("Default").IsDependentOn("Component");
Task ("Clean").Does (() =>
{
CleanDirectory ("./component/tools/");
CleanDirectories ("./Build/");
CleanDirectories ("./**/bin");
CleanDirectories ("./**/obj");
});
RunTarget (TARGET);