forked from Redth/ZXing.Net.Mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
117 lines (94 loc) · 3.79 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
#tool nuget:?package=XamarinComponent
#addin nuget:?package=Cake.XCode
#addin nuget:?package=Cake.Xamarin
#addin nuget:?package=Cake.Xamarin.Build
#addin nuget:?package=Cake.SemVer
#addin nuget:?package=Cake.FileHelpers
#addin nuget:?package=Cake.MonoApiTools
var PREVIEW = "";
var VERSION = EnvironmentVariable ("APPVEYOR_BUILD_VERSION") ?? Argument("version", "2.1.9999");
var NUGET_VERSION = VERSION;
var TARGET = Argument ("t", Argument ("target", "Default"));
// Build a semver string out of the preview if it's specified
if (!string.IsNullOrEmpty (PREVIEW)) {
var sv = ParseSemVer (VERSION);
NUGET_VERSION = CreateSemVer (sv.Major, sv.Minor, sv.Patch, PREVIEW).ToString ();
}
var buildSpec = new BuildSpec {
Samples = new [] {
new DefaultSolutionBuilder { SolutionPath = "./Samples/Android/Sample.Android.sln", BuildsOn = BuildPlatforms.Windows | BuildPlatforms.Mac },
new IOSSolutionBuilder { SolutionPath = "./Samples/iOS/Sample.iOS.sln", BuildsOn = BuildPlatforms.Mac },
new WpSolutionBuilder { SolutionPath = "./Samples/WindowsPhone/Sample.WindowsPhone.sln", BuildsOn = BuildPlatforms.Windows },
new DefaultSolutionBuilder { SolutionPath = "./Samples/WindowsUniversal/Sample.WindowsUniversal.sln", BuildsOn = BuildPlatforms.Windows },
new WpSolutionBuilder { SolutionPath = "./Samples/Forms/Sample.Forms.sln", BuildsOn = BuildPlatforms.Windows },
new WpSolutionBuilder { SolutionPath = "./Samples/Forms/Sample.Forms.WP8.sln", BuildsOn = BuildPlatforms.Windows },
},
// These should only get populated on windows where all the binaries will exist
NuGets = new NuGetInfo [] {},
Components = new Component [] {},
};
if (IsRunningOnWindows ()) {
buildSpec.Libs = new [] {
new WpSolutionBuilder {
SolutionPath = "./ZXing.Net.Mobile.sln",
Configuration = "ReleaseWin",
BuildsOn = BuildPlatforms.Windows,
},
new WpSolutionBuilder {
SolutionPath = "./ZXing.Net.Mobile.Forms.sln",
Configuration = "ReleaseWin",
BuildsOn = BuildPlatforms.Windows,
},
new WpSolutionBuilder {
SolutionPath = "./ZXing.Net.Mobile.WP8.sln",
BuildsOn = BuildPlatforms.Windows
},
};
buildSpec.NuGets = new [] {
new NuGetInfo { NuSpec = "./ZXing.Net.Mobile.nuspec", Version = NUGET_VERSION },
new NuGetInfo { NuSpec = "./ZXing.Net.Mobile.Forms.nuspec", Version = NUGET_VERSION },
};
buildSpec.Components = new [] {
new Component { ManifestDirectory = "./Component" },
new Component { ManifestDirectory = "./Component-Forms" },
};
} else {
buildSpec.Libs = new [] {
new DefaultSolutionBuilder {
SolutionPath = "./ZXing.Net.Mobile.sln",
Configuration = "ReleaseMac",
BuildsOn = BuildPlatforms.Mac,
},
new DefaultSolutionBuilder {
SolutionPath = "./ZXing.Net.Mobile.Forms.sln",
Configuration = "ReleaseMac",
BuildsOn = BuildPlatforms.Mac,
}
};
}
Task ("component-setup")
.IsDependentOn ("samples")
.IsDependentOn ("nuget")
.Does (() =>
{
var compVersion = VERSION;
if (compVersion.Contains ("-"))
compVersion = compVersion.Substring (0, compVersion.IndexOf ("-"));
// 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");
CopyFile ("./Component-Forms/component.template.yaml", "./Component-Forms/component.yaml");
// Replace version in template files
ReplaceTextInFiles ("./**/component.yaml", "{VERSION}", compVersion);
});
Task ("component").IsDependentOn ("component-setup").IsDependentOn ("component-base");
Task ("Default").IsDependentOn ("component");
Task ("clean").IsDependentOn ("clean-base").Does (() =>
{
CleanDirectories ("./Build/");
CleanDirectories ("./**/bin");
CleanDirectories ("./**/obj");
});
SetupXamarinBuildTasks (buildSpec, Tasks, Task);
RunTarget (TARGET);