This repository has been archived by the owner on Dec 27, 2024. It is now read-only.
forked from okta/okta-aspnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
135 lines (121 loc) · 3.3 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
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
Boolean.TryParse(EnvironmentVariable("TRAVIS"), out var travisEnabled);
Console.WriteLine($"\n Travis enabled: {travisEnabled}");
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(travisEnabled)
{
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(travisEnabled && 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")
.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("PackNuget")
.IsDependentOn("RunTests")
.Does(() =>
{
Projects
.Where(name => !name.Contains(".Test"))
.ToList()
.ForEach(name =>
{
Console.WriteLine($"\nCreating NuGet package for {name}");
if(travisEnabled && name == "Okta.AspNet.Abstractions")
{
var msBuildSettings = new DotNetCoreMSBuildSettings();
msBuildSettings.SetTargetFramework("netstandard2.0");
DotNetCorePack($"./{name}", new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = "./artifacts",
MSBuildSettings = msBuildSettings,
});
}
else
{
DotNetCorePack($"./{name}", new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = "./artifacts",
});
}
});
});
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("RunTests")
.IsDependentOn("PackNuget");
// Run the specified (or default) target
RunTarget(target);