-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
executable file
·139 lines (115 loc) · 3.37 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
#tool "GitVersion.CommandLine&version=4.0.0"
#addin nuget:?package=Cake.XmlDocMarkdown&version=1.4.2
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var buildVerbosity = Argument("buildVerbosity", Verbosity.Minimal);
// Define directories.
var solutionFile = GetFiles("./src/*.sln").First();
// iOS.
var iOSProject = GetFiles("./src/Xamarin.iOS.FluentAutoLayoutExtensions/*.csproj").First();
var iOSSample = GetFiles("./src/Xamarin.iOS.FluentAutoLayoutExtensions.Sample/*.csproj").First();
// Output folder.
var artifactsDirectory = Directory("./artifacts");
var iOSOutputDirectory = "bin/";
GitVersion currentVersion = null;
Setup(ctx =>
{
currentVersion = GitVersion(new GitVersionSettings
{
UpdateAssemblyInfo = false,
});
Information("Current gitversion is {0}", currentVersion.NuGetVersion);
Information("IsRunningOnBitRise {0}", BuildSystem.IsRunningOnBitrise);
if (BuildSystem.IsRunningOnBitrise)
{
BuildSystem.Bitrise.SetEnvironmentString("BITRISE_BUILD_NUMBER", currentVersion.NuGetVersion);
}
});
Task("Clean-Solution")
.IsDependentOn("Clean-ArtifactsFolder")
.Does(() =>
{
CleanDirectories ("./**/bin");
CleanDirectories ("./**/obj");
MSBuild(solutionFile, settings => settings
.SetConfiguration(configuration)
.WithTarget("Clean")
.SetVerbosity(buildVerbosity));
});
Task("Clean-ArtifactsFolder")
.Does(() =>
{
CleanDirectory(artifactsDirectory);
});
Task("Restore-Packages")
.Does(() =>
{
NuGetRestore(solutionFile);
});
Task("Prepare-Build")
.IsDependentOn("Clean-Solution")
.IsDependentOn("Restore-Packages")
.Does (() => {});
Task("Build")
.IsDependentOn("Build-Sample")
.IsDependentOn("Build-Library")
.Does(() => {});
Task("Build-Sample")
.IsDependentOn("Prepare-Build")
.Does(() =>
{
MSBuild(iOSSample, settings =>
settings.SetConfiguration(configuration)
.WithTarget("Build")
.WithProperty("Platform", "iPhoneSimulator")
.WithProperty("TreatWarningsAsErrors", "false")
.WithProperty("OutputPath", iOSOutputDirectory)
.SetVerbosity(buildVerbosity));
});
Task("Build-Library")
.IsDependentOn("Prepare-Build")
.Does(() =>
{
MSBuild(iOSProject, settings => settings
.SetConfiguration(configuration)
.WithTarget("Build")
.SetVerbosity(buildVerbosity));
});
Task ("NuGet")
.IsDependentOn("Build")
.IsDependentOn("Generate-Docs")
.Does (() =>
{
NuGetPack(
"./nuspec/Xamarin.iOS.FluentAutoLayoutExtensions.nuspec",
new NuGetPackSettings
{
Version = currentVersion.NuGetVersion,
Verbosity = NuGetVerbosity.Normal,
OutputDirectory = artifactsDirectory,
BasePath = "./src",
});
});
Task ("Publish-NuGetPackage")
.IsDependentOn ("NuGet")
.WithCriteria(() => BuildSystem.IsRunningOnBitrise)
.Does (() =>
{
var package = GetFiles(System.IO.Path.Combine(artifactsDirectory, "*.nupkg")).First();
NuGetPush(
package,
new NuGetPushSettings {
Source = Environment.GetEnvironmentVariable("NUGET_PACKAGE_SOURCE"),
ApiKey = Environment.GetEnvironmentVariable("NUGET_PACKAGE_APY_KEY")
});
});
Task ("Generate-Docs")
.IsDependentOn("Build")
.Does (() =>
{
XmlDocMarkdownGenerate($"./src/Xamarin.iOS.FluentAutoLayoutExtensions/bin/{configuration}/Xamarin.iOS.FluentAutoLayoutExtensions.dll", "./docs");
});
Task("Default")
.IsDependentOn("NuGet")
.Does(() => {});
RunTarget(target);