-
Notifications
You must be signed in to change notification settings - Fork 157
/
build.cake
117 lines (98 loc) · 3.12 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
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var npmPath = (IsRunningOnWindows()
? Context.Tools.Resolve("npm.cmd")
: Context.Tools.Resolve("npm"))
?? throw new Exception("Failed to resolve npm, make sure Node is installed.");
//////////////////////////////////////////////////////////////////////
// PARAMETERS
//////////////////////////////////////////////////////////////////////
var project = "CoreWiki";
var solution = $"./{project}.sln";
var tests = $"./{project}.Test/{project}.Test.csproj";
var publishPath = MakeAbsolute(Directory("./output"));
//////////////////////////////////////////////////////////////////////
// HELPERS
//////////////////////////////////////////////////////////////////////
Action<FilePath, DirectoryPath, ProcessArgumentBuilder> Cmd => (path, workingPath, args) => {
var result = StartProcess(
path,
new ProcessSettings {
Arguments = args,
WorkingDirectory = workingPath
});
if(0 != result)
{
throw new Exception($"Failed to execute tool {path.GetFilename()} ({result})");
}
};
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("Clean")
.Does( () => {
CleanDirectories($"./{project}/obj/**/*.*");
CleanDirectories($"./{project}/bin/{configuration}/**/*.*");
});
Task("Clean-Publish")
.IsDependentOn("Clean")
.Does( () => {
CleanDirectory(publishPath);
});
Task("NPM-Install")
.IsDependentOn("Clean")
.Does( ()=> {
Cmd(npmPath,
$"./{project}",
new ProcessArgumentBuilder()
.Append("install")
);
});
Task("Restore")
.IsDependentOn("NPM-Install")
.IsDependentOn("Clean")
.Does( () => {
DotNetCoreRestore(solution);
});
Task("Build")
.IsDependentOn("Restore")
.Does( () => {
DotNetCoreBuild(solution,
new DotNetCoreBuildSettings {
NoRestore = true,
Configuration = configuration
});
});
Task("Test")
.IsDependentOn("Build")
.Does( () => {
DotNetCoreTest(tests,
new DotNetCoreTestSettings {
NoBuild = true,
NoRestore = true,
Configuration = configuration,
ResultsDirectory = "./testresults",
ArgumentCustomization = args => args.Append("--logger:xunit;LogFilePath=test_result.xml")
});
});
Task("Publish")
.IsDependentOn("Test")
.IsDependentOn("Clean-Publish")
.Does( () => {
DotNetCorePublish(solution,
new DotNetCorePublishSettings {
NoRestore = true,
Configuration = configuration,
OutputDirectory = publishPath
});
});
Task("Default")
.IsDependentOn("Test");
Task("AppVeyor")
.IsDependentOn("Publish");
Task("Travis")
.IsDependentOn("Test");
RunTarget(target);