forked from Redth/ZXing.Net.Mobile
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.cake
100 lines (72 loc) · 2.66 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
var target = Argument("target", "libs");
var version = Argument("nugetversion", "");
List<string> GetSamples ()
{
var l = new List<string> ();
l.Add ("Samples/Android/Sample.Android.sln");
l.Add ("Samples/iOS/Sample.iOS.sln");
l.Add ("Samples/iOS/Sample.iOS-Classic.sln");
if (IsRunningOnWindows ()) {
l.Add ("Samples/WindowsPhone8/Sample.WindowsPhone8.sln");
}
return l;
}
var slns = GetSamples ();
Task ("libs").Does (() =>
{
// Build the PCL
NuGetRestore ("ZXing.Net.Mobile.sln");
DotNetBuild ("src/ZXing.Net.Mobile.Portable/ZXing.Net.Mobile.Portable.csproj", c => c.Configuration = "Release");
foreach (var s in slns) {
// Build each project
NuGetRestore (s);
DotNetBuild (s, c => c.Configuration = "Release");
}
});
Task ("tools").WithCriteria (!FileExists ("./Component/tools/xamarin-component.exe")).Does (() =>
{
if (!DirectoryExists ("./Component/tools/"))
CreateDirectory ("./Component/tools/");
DownloadFile ("https://components.xamarin.com/submit/xpkg", "./Component/tools/tools.zip");
Unzip ("./Component/tools/tools.zip", "./Component/tools/");
DeleteFile ("./Component/tools/tools.zip");
});
Task ("component").IsDependentOn ("libs").IsDependentOn ("tools").Does (() =>
{
DeleteFiles ("./Build/**/*.xml");
if (IsRunningOnWindows ())
StartProcess ("./Component/tools/xamarin-component.exe", new ProcessSettings { Arguments = "package ./" });
else
StartProcess ("mono", new ProcessSettings { Arguments = "./Component/tools/xamarin-component.exe package ./" });
});
Task ("nuget").IsDependentOn ("libs").Does (() =>
{
NuGetPack ("./ZXing.Net.Mobile.nuspec", new NuGetPackSettings { OutputDirectory = "./NuGet/" });
});
Task ("publish").IsDependentOn ("nuget").IsDependentOn ("component")
.Does (() =>
{
if (string.IsNullOrEmpty (version)) {
Information ("No version specified, not publishing anything.");
return;
}
var apiKey = TransformTextFile("./nuget_api_key.txt").ToString ().Trim ();
StartProcess ("nuget", new ProcessSettings { Arguments = "push ./NuGet/ZXing.Net.Mobile." + version + ".nupkg " + apiKey });
});
Task ("stage").IsDependentOn ("nuget").Does (() =>
{
if (string.IsNullOrEmpty (version)) {
Information ("No version specified, not publishing anything.");
return;
}
var apiKey = TransformTextFile("./myget_api_key.txt").ToString ().Trim ();
StartProcess ("nuget", new ProcessSettings { Arguments = "push ./NuGet/ZXing.Net.Mobile." + version + ".nupkg -Source https://www.myget.org/F/redth/api/v2 " + apiKey });
});
Task ("clean").Does (() =>
{
CleanDirectory ("./Component/tools/");
CleanDirectories ("./Build/");
CleanDirectories ("./**/bin");
CleanDirectories ("./**/obj");
});
RunTarget (target);