-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
164 lines (145 loc) · 5.8 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
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.9.0"
#addin "nuget:?package=Cake.DoInDirectory&version=3.2.0"
#addin "Cake.FileHelpers&version=3.1.0"
#addin "Cake.XComponent&version=6.0.1"
#addin "Cake.Incubator&version=3.0.0"
#load "cake.scripts/utilities.cake"
var target = Argument("target", "Build");
var buildConfiguration = Argument("buildConfiguration", "Debug");
var version = Argument("buildVersion", "1.0.0");
var vsVersion = Argument("vsVersion", "VS2017");
var apiKey = Argument("nugetKey", "");
var setAssemblyVersion = Argument<bool>("setAssemblyVersion", false);
Task("Clean")
.Does(() =>
{
CleanDirectory("nuget");
CleanDirectory("packaging");
CleanDirectory("./ReactiveXComponent/bin");
CleanDirectory("./ReactiveXComponent/obj");
CleanDirectory("./ReactiveXComponentTest/bin");
CleanDirectory("./ReactiveXComponentTest/obj");
var pathHelloWorldIntegrationTest = "./docker/integration_tests/XCProjects/HelloWorldV5/";
CleanDirectory(pathHelloWorldIntegrationTest + "xcr");
CleanDirectory(pathHelloWorldIntegrationTest + "generated");
CleanDirectory(pathHelloWorldIntegrationTest + "rxcAssemblies");
CleanDirectory(pathHelloWorldIntegrationTest + "CreateInstancesReactiveApi/CreateInstances/xcassemblies");
CleanDirectory(pathHelloWorldIntegrationTest + "CreateInstancesReactiveApi/CreateInstances/bin");
CleanDirectory(pathHelloWorldIntegrationTest + "CreateInstancesReactiveApi/CreateInstances/obj");
});
Task("Build")
.Does(() =>
{
DotNetCoreRestore("ReactiveXComponent.sln");
DotNetCoreBuild(
"ReactiveXComponent.sln",
new DotNetCoreBuildSettings {
Configuration = buildConfiguration,
VersionSuffix = version,
MSBuildSettings = new DotNetCoreMSBuildSettings{}.SetVersion(version),
});
});
Task("Test")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = buildConfiguration
};
var projectFiles = GetFiles("./**/*Test.csproj");
foreach(var file in projectFiles)
{
DotNetCoreTest(file.FullPath, settings);
}
});
Task("CreatePackage")
.Does(() =>
{
DotNetCorePack(
"ReactiveXComponent/ReactiveXComponent.csproj",
new DotNetCorePackSettings {
Configuration = buildConfiguration,
IncludeSymbols = true,
NoBuild = true,
OutputDirectory = @"nuget",
VersionSuffix = version,
MSBuildSettings = new DotNetCoreMSBuildSettings{}.SetVersion(version),
}
);
});
Task("PushPackage")
.Does(() =>
{
if (!string.IsNullOrEmpty(apiKey))
{
DoInDirectory("./nuget", () =>
{
var package = "./ReactiveXComponent.Net." + version + ".nupkg";
DotNetCoreNuGetPush(package, new DotNetCoreNuGetPushSettings
{
Source = "https://api.nuget.org/v3/index.json",
ApiKey = apiKey
});
});
}
else
{
Error("No Api Key provided. Can't deploy package to Nuget.");
}
});
Task("All")
.IsDependentOn("Clean")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("CreatePackage")
.Does(() =>
{
});
Task("BuildHelloWorld")
.Does(() =>
{
var exitCode = 0;
var helloWorldProjectPathParam = " --project=\"./docker/integration_tests/XCProjects/HelloWorldV5/HelloWorldV5_Model.xcml\"";
var mono = "mono";
var xcbuild = GetXcBuildPath();
var cleanArgs = " --compilationmode=Debug --clean --env=Dev --vs=";
var buildArgs = " --compilationmode=Debug --build --env=Dev --vs=";
if (IsRunningOnUnix()) {
exitCode = StartProcess(mono, xcbuild + cleanArgs + vsVersion + helloWorldProjectPathParam + GetXCBuildExtraParam());
StartProcess(mono, xcbuild + buildArgs + vsVersion + helloWorldProjectPathParam + GetXCBuildExtraParam());
} else {
exitCode = StartProcess(xcbuild, cleanArgs + vsVersion + helloWorldProjectPathParam + GetXCBuildExtraParam());
StartProcess(xcbuild, buildArgs + vsVersion + helloWorldProjectPathParam + GetXCBuildExtraParam());
}
if (exitCode != 0) {
throw new Exception();
}
});
Task("BuildIntegrationTests")
.IsDependentOn("BuildHelloWorld")
.Does(() =>
{
var rxcAssembliesPatterns = new string[]
{
"./packaging/ReactiveXComponent.dll"
};
var pathTIDirectory = "./docker/integration_tests/XCProjects/HelloWorldV5/CreateInstancesReactiveApi";
var pathrxcAssembliesDirectory = "./docker/integration_tests/XCProjects/HelloWorldV5/rxcAssemblies";
var rxcAssemblies = GetFiles(rxcAssembliesPatterns);
CreateDirectory(pathrxcAssembliesDirectory);
CopyFiles(rxcAssemblies, pathrxcAssembliesDirectory);
DotNetCoreRestore(pathTIDirectory + "/CreateInstances.sln");
DotNetCoreBuild(
pathTIDirectory + "/CreateInstances.sln",
new DotNetCoreBuildSettings {
Configuration = buildConfiguration,
});
});
Task("PackageDockerIntegrationTests")
.Does(() =>
{
Zip( GetXcRuntimeDirectory(), "./docker/integration_tests/dockerScripts/XCContainer/XCRuntime.zip");
Zip("./docker/integration_tests/XCProjects/HelloWorldV5/xcr/xcassemblies", "./docker/integration_tests/dockerScripts/XCContainer/HelloWorldV5XCassemblies.zip");
Zip("./docker/integration_tests/XCProjects/HelloWorldV5/CreateInstancesReactiveApi/CreateInstances/bin/" + buildConfiguration + "/netcoreapp2.1", "./docker/integration_tests/dockerScripts/AppsContainer/CreateInstanceReactiveApi.zip");
});
RunTarget(target);