This repository has been archived by the owner on Jun 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.cake
183 lines (149 loc) · 4.9 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#tool nuget:?package=GitVersion.CommandLine
#tool nuget:?package=vswhere
var sln = new FilePath("SGTabbedPager.sln");
var project = new FilePath("SGTabbedPager/SGTabbedPager.csproj");
var projectMvx = new FilePath("SGTabbedPagerMvx/SGTabbedPagerMvx.csproj");
var binDir = new DirectoryPath("SGTabbedPager/bin/Release");
var binDirMvx = new DirectoryPath("SGTabbedPagerMvx/bin/Release");
var nuspec = new FilePath("SGTabbedPager.nuspec");
var nuspecMvx = new FilePath("SGTabbedPagerMvx.nuspec");
var outputDir = new DirectoryPath("artifacts");
var target = Argument("target", "Default");
var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
var releaseNotes = ParseReleaseNotes("./releasenotes.md").Notes.ToArray();
Task("Clean").Does(() =>
{
CleanDirectories("./**/bin");
CleanDirectories("./**/obj");
CleanDirectories(outputDir.FullPath);
});
FilePath msBuildPath;
Task("ResolveBuildTools")
.Does(() =>
{
var vsLatest = VSWhereLatest();
msBuildPath = (vsLatest == null)
? null
: vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");
});
GitVersion versionInfo = null;
Task("Version").Does(() => {
var branchName = AppVeyor.Environment.Repository.Branch;
GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.BuildServer,
Branch = branchName
});
versionInfo = GitVersion(new GitVersionSettings {
OutputType = GitVersionOutput.Json,
Branch = branchName
});
Information("VI:\t{0}", versionInfo.FullSemVer);
});
Task("Restore").Does(() => {
NuGetRestore(sln);
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Version")
.IsDependentOn("Restore")
.IsDependentOn("ResolveBuildTools")
.Does(() => {
var settings = new MSBuildSettings
{
Configuration = "Release",
ToolPath = msBuildPath
};
settings.Properties.Add("Platform", new [] {"iPhone"});
MSBuild(sln, settings);
});
Task("Package")
.IsDependentOn("Build")
.Does(() => {
EnsureDirectoryExists(outputDir);
var dllDir = binDir + "/SGTabbedPager.*";
Information("Dll Dir: {0}", dllDir);
var nugetContent = new List<NuSpecContent>();
foreach(var dll in GetFiles(dllDir)){
var dllString = dll.ToString();
if (dllString.EndsWith(".mdb"))
continue;
Information("File: {0}", dll.ToString());
nugetContent.Add(new NuSpecContent {
Target = "lib/Xamarin.iOS10",
Source = dllString
});
}
Information("File Count {0}", nugetContent.Count);
NuGetPack(nuspec, new NuGetPackSettings {
Authors = new [] { "Tomasz Cielecki" },
Owners = new [] { "Tomasz Cielecki" },
IconUrl = new Uri("http://i.imgur.com/V3983YY.png"),
ProjectUrl = new Uri("https://github.com/Cheesebaron/SGTabbedPager"),
LicenseUrl = new Uri("https://github.com/Cheesebaron/SGTabbedPager/blob/master/LICENSE"),
Copyright = "Copyright (c) Tomasz Cielecki",
RequireLicenseAcceptance = false,
Tags = new [] {"monotouch", "ui", "pager", "xamarin", "ios"},
Version = versionInfo.NuGetVersion,
ReleaseNotes = releaseNotes,
Symbols = false,
NoPackageAnalysis = true,
OutputDirectory = outputDir,
Verbosity = NuGetVerbosity.Detailed,
Files = nugetContent,
BasePath = "/."
});
});
Task("PackageMvx")
.IsDependentOn("Build")
.Does(() => {
EnsureDirectoryExists(outputDir);
var dllDir = binDirMvx + "/SGTabbedPagerMvx.*";
Information("Dll Dir: {0}", dllDir);
var nugetContent = new List<NuSpecContent>();
foreach(var dll in GetFiles(dllDir)){
var dllString = dll.ToString();
if (dllString.EndsWith(".mdb"))
continue;
Information("File: {0}", dll.ToString());
nugetContent.Add(new NuSpecContent {
Target = "lib/Xamarin.iOS10",
Source = dllString
});
}
Information("File Count {0}", nugetContent.Count);
NuGetPack(nuspecMvx, new NuGetPackSettings {
Authors = new [] { "Tomasz Cielecki" },
Owners = new [] { "Tomasz Cielecki" },
IconUrl = new Uri("http://i.imgur.com/V3983YY.png"),
ProjectUrl = new Uri("https://github.com/Cheesebaron/SGTabbedPager"),
LicenseUrl = new Uri("https://github.com/Cheesebaron/SGTabbedPager/blob/master/LICENSE"),
Copyright = "Copyright (c) Tomasz Cielecki",
RequireLicenseAcceptance = false,
Tags = new [] {"monotouch", "mvvmcross", "ui", "pager", "xamarin", "ios"},
Version = versionInfo.NuGetVersion,
ReleaseNotes = releaseNotes,
Symbols = false,
NoPackageAnalysis = true,
OutputDirectory = outputDir,
Verbosity = NuGetVerbosity.Detailed,
Files = nugetContent,
BasePath = "/."
});
});
Task("UploadAppVeyorArtifact")
.IsDependentOn("Package")
.IsDependentOn("PackageMvx")
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isRunningOnAppVeyor)
.Does(() => {
Information("Artifacts Dir: {0}", outputDir.FullPath);
foreach(var file in GetFiles(outputDir.FullPath + "/*")) {
Information("Uploading {0}", file.FullPath);
AppVeyor.UploadArtifact(file.FullPath);
}
});
Task("Default")
.IsDependentOn("UploadAppVeyorArtifact");
RunTarget(target);