-
Notifications
You must be signed in to change notification settings - Fork 52
/
build.cake
172 lines (151 loc) · 4.36 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
#addin nuget:?package=Cake.Figlet&version=1.3.1
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
Boolean.TryParse(EnvironmentVariable("CIRCLE_CI"), out var circleCiEnabled);
Console.WriteLine($"\n Circle Ci enabled: {circleCiEnabled}");
Console.WriteLine($"\n Jenkins build: {BuildSystem.IsRunningOnJenkins}");
var Projects = new List<string>()
{
"Okta.AspNet.Abstractions",
"Okta.AspNet.Abstractions.Test",
"Okta.AspNet",
"Okta.AspNet.Test",
"Okta.AspNetCore",
"Okta.AspNetCore.Test"
};
// Ignoring .NET 4.5.2 projects as it is causing issues with travis.
// https://github.com/okta/okta-aspnet/issues/40
var netCoreProjects = new List<string>()
{
"Okta.AspNet.Abstractions",
"Okta.AspNet.Abstractions.Test",
"Okta.AspNetCore",
"Okta.AspNetCore.Test"
};
if(circleCiEnabled)
{
Projects = netCoreProjects;
}
Task("Clean").Does(() =>
{
Console.WriteLine("Removing ./artifacts");
CleanDirectory("./artifacts/");
Console.WriteLine("Removing nested bin and obj directories");
GetDirectories("./**/bin")
.Concat(GetDirectories("./**/obj"))
.ToList()
.ForEach(d => CleanDirectory(d));
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
Projects.ForEach(name =>
{
Console.WriteLine($"\nRestoring packages for {name}");
DotNetCoreRestore($"./{name}");
});
});
Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
Projects.ForEach(name =>
{
Console.WriteLine($"\nBuilding {name}");
if(circleCiEnabled && name == "Okta.AspNet.Abstractions")
{
DotNetCoreBuild($"./{name}", new DotNetCoreBuildSettings
{
Configuration = configuration,
Framework = "netstandard2.0",
});
}
else
{
DotNetCoreBuild($"./{name}", new DotNetCoreBuildSettings
{
Configuration = configuration,
});
}
});
});
Task("RunTests")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("Strongname")
.Does(() =>
{
Projects
.Where(name => name.EndsWith(".Test")) // For now, we won't run integration tests in CI
.ToList()
.ForEach(name => {
DotNetCoreTest(string.Format("./{0}/{0}.csproj", name));
});
});
Task("Strongname")
.IsDependentOn("Build")
.Does(() =>
{
if (!circleCiEnabled)
{
var snBinaries = GetFiles("./Okta.AspNet/bin/Release/net4*/Okta.AspNet.dll")
.Concat(GetFiles("./Okta.AspNet.Abstractions/bin/Release/net4*/Okta.AspNet.Abstractions.dll"))
.Concat(GetFiles("./Okta.AspNet.Test/bin/Release/net4*/Okta.AspNet.Test.dll"));
foreach (var binary in snBinaries)
{
StartProcess("sn.exe", $"-Rc \"{binary}\" OktaDotnetStrongname");
}
}
});
Task("PackNuget")
.IsDependentOn("RunTests")
.IsDependentOn("Strongname")
.Does(() =>
{
Projects
.Where(name => !name.Contains(".Test"))
.ToList()
.ForEach(name =>
{
Console.WriteLine($"\nCreating NuGet package for {name}");
if(circleCiEnabled && name == "Okta.AspNet.Abstractions")
{
var msBuildSettings = new DotNetCoreMSBuildSettings();
msBuildSettings.SetTargetFramework("netstandard2.0");
DotNetCorePack($"./{name}", new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = "./artifacts",
MSBuildSettings = msBuildSettings,
NoBuild = true,
});
}
else
{
DotNetCorePack($"./{name}", new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = "./artifacts",
NoBuild = true,
});
}
});
});
Task("Info")
.Does(() =>
{
Information(Figlet("Okta.AspNet"));
var cakeVersion = typeof(ICakeContext).Assembly.GetName().Version.ToString();
Information("Building using {0} version of Cake", cakeVersion);
});
Task("Default")
.IsDependentOn("Info")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("Strongname")
.IsDependentOn("RunTests")
.IsDependentOn("PackNuget");
// Run the specified (or default) target
RunTarget(target);