-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
108 lines (82 loc) · 2.78 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
#addin "Cake.Incubator"
#tool "nuget:?package=xunit.runner.console"
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
// Path to the project.json
var projDir = ""; // Project Directory
var solutionFile = "LockOnCode.VirtualMachine.sln"; // Solution file if needed
var outputDir = Directory("Build") + Directory(configuration); // The output directory the build artifacts saved too
var report = outputDir;
var xunitReport = report;
var buildSettings = new DotNetCoreBuildSettings
{
Framework = "netcoreapp2.0 ",
Configuration = "Release",
OutputDirectory = outputDir
};
Task("Clean")
.Does(() => {
if (DirectoryExists(outputDir))
{
DeleteDirectory(outputDir, recursive:true);
}
//Clean test output
var directoryToScanForTestResults = "./**/TestResults/*.trx";
var testResultFiles = GetFiles(directoryToScanForTestResults);
foreach(var file in testResultFiles)
{
Information("Deleting test result" + file.ToString());
}
DeleteFiles(testResultFiles);
});
Task("Restore")
.Does(() => {
DotNetCoreRestore(solutionFile);
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.Does(() => {
DotNetCoreBuild(solutionFile, buildSettings);
});
Task("UnitTest")
.IsDependentOn("Build")
.Does(() => {
Information("Start Running Tests");
var testSettings = new DotNetCoreTestSettings
{
NoBuild = true,
DiagnosticOutput = true,
Configuration = "Debug",
Logger = "trx",
OutputDirectory = outputDir
};
Information(Environment.CurrentDirectory);
var directoryToScanForTests = "./**/*Tests.csproj";
Information("Scanning directory for tests: " + directoryToScanForTests);
var testProjects = GetFiles(directoryToScanForTests);
foreach(var testProject in testProjects)
{
Information("Found Test Project: " + testProject);
DotNetCoreTest(testProject.ToString(), testSettings);
}
});
Task("Package")
.IsDependentOn("Build")
.Does(() => {
var packSettings = new DotNetCorePackSettings
{
OutputDirectory = outputDir,
NoBuild = true
};
//DotNetCorePack(projJson, packSettings);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("UnitTest");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);