-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
219 lines (186 loc) · 6.41 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#load cake\TargetEnvironment.cake
#addin "Cake.FileHelpers&version=5.0.0"
#addin "Cake.Incubator&version=7.0.0"
// VARS
var version = Argument("build-version", "0.1.0");
var packageVersion = Argument("package-version", "0.1.0");
var configuration = Argument("configuration", "Release");
var target = Argument("target", "Default");
var msbuildsettings = new DotNetMSBuildSettings();
var supportedVersionBands = new List<string>() {"7.0.100-rc.2", "7.0.100", "7.0.200"};
const string manifestName = "Trungnt2910.NET.Sdk.Browser";
var manifestPack = $"{manifestName}.Manifest-{TargetEnvironment.DotNetCliFeatureBand}.{packageVersion}.nupkg";
var manifestPackPath = $"out/nuget/{manifestPack}";
var packNames = new List<string>()
{
"Trungnt2910.Browser.Ref",
"Trungnt2910.Browser.Runtime",
"Trungnt2910.Browser.Sdk"
};
var coreLibraryNames = new List<string>()
{
"Trungnt2910.Browser"
};
// TASKS
Task("Init")
.Does(() =>
{
Console.WriteLine("Version: " + version);
Console.WriteLine("Package Version: " + packageVersion);
// Assign some common properties
msbuildsettings = msbuildsettings.WithProperty("Version", version);
msbuildsettings = msbuildsettings.WithProperty("PackageVersion", packageVersion);
msbuildsettings = msbuildsettings.WithProperty("Authors", "Trung Nguyen");
msbuildsettings = msbuildsettings.WithProperty("_BrowserVersion", version);
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
foreach (var name in coreLibraryNames)
{
DotNetRestore($"src/{name}/{name}.csproj");
}
foreach (var name in packNames)
{
DotNetRestore($"workload/{name}/{name}.csproj");
}
DotNetRestore("workload/Trungnt2910.NET.Sdk.Browser/Trungnt2910.NET.Sdk.Browser.csproj");
});
Task("Clean")
.IsDependentOn("Init")
.Does(() =>
{
});
Task("FullClean")
.IsDependentOn("Clean")
.Does(() =>
{
DeleteDirectory("out", new DeleteDirectorySettings {
Recursive = true,
Force = true
});
});
Task("BuildCoreLibraries")
.IsDependentOn("Restore")
.Does(() =>
{
var settings = new DotNetBuildSettings
{
Configuration = configuration,
MSBuildSettings = msbuildsettings,
NoRestore = true
};
foreach (var name in coreLibraryNames)
{
DotNetBuild($"src/{name}/{name}.csproj", settings);
}
});
Task("BuildAndPackageWorkload")
.IsDependentOn("BuildCoreLibraries")
.Does(() =>
{
var buildSettings = new DotNetBuildSettings
{
MSBuildSettings = msbuildsettings,
Configuration = configuration,
NoRestore = true,
// Don't build the core libraries
NoDependencies = true,
// Always re-generate files.
NoIncremental = true
};
var packSettings = new DotNetPackSettings
{
MSBuildSettings = msbuildsettings,
Configuration = configuration,
OutputDirectory = "out/nuget",
NoRestore = true,
NoBuild = true,
NoDependencies = true
};
foreach (var name in packNames)
{
DotNetBuild($"workload/{name}/{name}.csproj", buildSettings);
DotNetPack($"workload/{name}/{name}.csproj", packSettings);
}
foreach (var band in supportedVersionBands)
{
buildSettings.MSBuildSettings = buildSettings.MSBuildSettings.WithProperty("_BrowserManifestVersionBand", band);
DotNetBuild("workload/Trungnt2910.NET.Sdk.Browser/Trungnt2910.NET.Sdk.Browser.csproj", buildSettings);
packSettings.MSBuildSettings = packSettings.MSBuildSettings.WithProperty("_BrowserManifestVersionBand", band);
DotNetPack("workload/Trungnt2910.NET.Sdk.Browser/Trungnt2910.NET.Sdk.Browser.csproj", packSettings);
}
});
Task("InstallWorkload")
.IsDependentOn("BuildAndPackageWorkload")
.Does(() =>
{
Console.WriteLine($"Installing workload for SDK version {TargetEnvironment.DotNetCliFeatureBand}, at {TargetEnvironment.DotNetInstallPath}");
Console.WriteLine($"Installing manifests to {TargetEnvironment.DotNetManifestPath}");
TargetEnvironment.InstallManifests(manifestName, manifestPackPath);
Console.WriteLine($"Installing packs to {TargetEnvironment.DotNetPacksPath}");
foreach (var name in packNames)
{
Console.WriteLine($"Installing {name}");
var pack = $"{name}.{packageVersion}.nupkg";
var packPath = $"out/nuget/{pack}";
TargetEnvironment.InstallPack(name, packageVersion, packPath);
}
Console.WriteLine($"Registering \"browser\" installed workload...");
TargetEnvironment.RegisterInstalledWorkload("browser");
});
Task("UninstallWorkload")
.Does(() =>
{
Console.WriteLine($"Uninstalling workload for SDK version {TargetEnvironment.DotNetCliFeatureBand}, at {TargetEnvironment.DotNetInstallPath}");
Console.WriteLine($"Removing manifests from {TargetEnvironment.DotNetManifestPath}");
TargetEnvironment.UninstallManifests(manifestName);
Console.WriteLine($"Removing packs from {TargetEnvironment.DotNetPacksPath}");
foreach (var name in packNames)
{
Console.WriteLine($"Removing {name}");
TargetEnvironment.UninstallPack(name, version);
}
Console.WriteLine($"Unregistering \"browser\" installed workload...");
TargetEnvironment.UnregisterInstalledWorkload("browser");
});
Task("BuildAndPackageTestFramework")
.IsDependentOn("Init")
.Does(() =>
{
var packSettings = new DotNetPackSettings
{
MSBuildSettings = msbuildsettings,
Configuration = configuration,
OutputDirectory = "out/nuget",
};
DotNetPack($"tests/Trungnt2910.Browser.ObservationFramework/Trungnt2910.Browser.ObservationFramework/Trungnt2910.Browser.ObservationFramework.csproj", packSettings);
});
Task("RunWorkloadTests")
.IsDependentOn("BuildAndPackageTestFramework")
.Does(() =>
{
var testSettings = new DotNetTestSettings
{
Configuration = configuration,
};
DotNetTest("tests/Trungnt2910.Browser.Tests/Trungnt2910.Browser.Tests.csproj", testSettings);
});
Task("BuildAndPackageAdditionalNuGetPackages")
.IsDependentOn("Init")
.Does(() =>
{
var packSettings = new DotNetPackSettings
{
MSBuildSettings = msbuildsettings,
Configuration = configuration,
OutputDirectory = "out/nuget",
};
DotNetPack("sample/Rickroller/Rickroller.csproj", packSettings);
});
// TASK TARGETS
Task("Default")
.IsDependentOn("BuildAndPackageWorkload");
// EXECUTION
RunTarget(target);