forked from Redth/ZXing.Net.Mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
115 lines (88 loc) · 3.38 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
#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", "Default");
var version = EnvironmentVariable ("APPVEYOR_BUILD_VERSION") ?? Argument("version", "2.0.0.9999");
var libs = new Dictionary<string, string> {
{ "./ZXing.Net.Mobile.sln", "Any" },
{ "./ZXing.Net.Mobile.Forms.sln", "Any" }
};
var samples = new Dictionary<string, string> {
{ "./Samples/Android/Sample.Android.sln", "Any" },
{ "./Samples/iOS/Sample.iOS.sln", "Mac" },
{ "./Samples/WindowsPhone/Sample.WindowsPhone.sln", "Win" },
{ "./Samples/WindowsUniversal/Sample.WindowsUniversal.sln", "Win" },
{ "./Samples/Forms/Sample.Forms.sln", "Win" },
};
// Used to build a dictionary of .sln files
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 ("libs").Does (() =>
{
buildAction (libs);
});
Task ("samples")
.IsDependentOn ("libs")
.Does (() =>
{
buildAction (samples);
});
Task ("nuget").IsDependentOn ("samples").Does (() =>
{
// Make sure our output path is there
if (!DirectoryExists ("./Build/nuget/"))
CreateDirectory ("./Build/nuget");
// Package our nuget
NuGetPack ("./ZXing.Net.Mobile.nuspec", new NuGetPackSettings { OutputDirectory = "./Build/nuget/", Version = version });
NuGetPack ("./ZXing.Net.Mobile.Forms.nuspec", new NuGetPackSettings { OutputDirectory = "./Build/nuget/", Version = version });
});
Task ("component")
.IsDependentOn ("samples")
.IsDependentOn ("nuget")
.Does (() =>
{
// 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}", version);
var xamCompSettings = new XamarinComponentSettings { ToolPath = "./tools/xamarin-component.exe" };
// Package both components
PackageComponent ("./Component/", xamCompSettings);
PackageComponent ("./Component-Forms/", xamCompSettings);
});
Task ("Default").IsDependentOn ("component");
Task ("clean").Does (() =>
{
CleanDirectory ("./Component/tools/");
CleanDirectories ("./Build/");
CleanDirectories ("./**/bin");
CleanDirectories ("./**/obj");
});
RunTarget (target);