-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
103 lines (87 loc) · 2.74 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
#addin "nuget:?package=NuGet.Core"
#addin "Cake.FileHelpers"
#addin "Cake.Incubator"
#addin "Cake.Npm"
#tool "nuget:?package=vswhere"
var target = Argument("target", "Default");
var buildNumber = Argument("buildnumber", "0");
var dropPath = Argument("drop_path", "./drop");
var stagingPath = "./staging";
var buildDir = Directory("./artifacts");
var configuration = "Release";
var solution = "./WCA.sln";
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
MSBuild(solution, settings => settings
.SetConfiguration(Argument("Configuration", configuration))
.SetVerbosity(Verbosity.Minimal)
.UseToolVersion(MSBuildToolVersion.VS2017)
.WithTarget("Clean")
);
});
Task("RestorePackages")
.Does(() =>
{
// NuGetRestore(solution);
DotNetCoreRestore();
NpmInstall(settings => settings.FromPath("./src/WCA.Web/"));
});
Task("Build")
.IsDependentOn("RestorePackages")
.Does(() =>
{
// Build backend / dotnet
MSBuild(solution, settings => settings
.SetConfiguration(Argument("Configuration", configuration))
.SetVerbosity(Verbosity.Minimal)
.UseToolVersion(MSBuildToolVersion.VS2017)
);
// Build frontend SPA with webpack
NpmRunScript("webpack", settings => settings.FromPath("./src/WCA.Web/"));
});
Task("RunTests")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Logger = "trx",
NoBuild = true, // Don't build because we're dependent on build anyway
Configuration = Argument("Configuration", configuration)
};
// Only run unit tests here. Integration tests must be called separately due to
// their dependence on configuration.
DotNetCoreTest("./test/WCA.UnitTests/", settings);
});
Task("Publish")
.IsDependentOn("RunTests")
.Does(() =>
{
if (DirectoryExists(stagingPath))
CleanDirectory(stagingPath);
if (DirectoryExists(dropPath))
CleanDirectory(dropPath);
EnsureDirectoryExists(stagingPath);
EnsureDirectoryExists(dropPath);
var webPublishPath = stagingPath + "/WCA.Web";
DotNetCorePublish("./src/WCA.Web", new DotNetCorePublishSettings
{
Configuration = configuration,
OutputDirectory = webPublishPath,
NoRestore = true
});
Zip(webPublishPath, dropPath + "/WCA.Web.zip");
var funcPublishPath = stagingPath + "/WCA.AzureFunctions";
DotNetCorePublish("./src/WCA.AzureFunctions", new DotNetCorePublishSettings
{
Configuration = configuration,
OutputDirectory = funcPublishPath,
NoRestore = true
});
Zip(funcPublishPath, dropPath + "/WCA.AzureFunctions.zip");
});
Task("Default")
.IsDependentOn("RunTests");
RunTarget(target);