-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.cake
118 lines (108 loc) · 3.53 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
#tool "nuget:?package=GitVersion.CommandLine"
#tool "nuget:?package=xunit.runner.console"
var target = Argument("target", "Test");
string version = "";
const string outputDir = "out";
const string buildPlatform = "AnyCPU";
const string configuration = "Release";
public static void EnsureDirExists(string path){
if (!System.IO.Directory.Exists(path)) {
System.IO.Directory.CreateDirectory(path);
}
}
Task("Paket Restore")
.Does(() =>
{
string command = @"if (-not (Test-Path .\.paket\paket.exe)) { .\.paket\paket.bootstrapper.exe }; .\.paket\paket.exe restore";
Information("Running command: {0}", command);
var settings = new ProcessSettings
{
Arguments = string.Format("-NoProfile -Command \"{0}\"", command)
};
var exitCodeWithArgument = StartProcess("powershell", settings);
if (exitCodeWithArgument != 0) {
throw new Exception("Something bad happened. Exit code: " + exitCodeWithArgument);
}
});
Task("Paket Outdated")
.IsDependentOn("Paket Restore")
.Does(() =>
{
string command = "$ok = $true; " +
"./.paket/paket.exe outdated | %{ " +
@"$ok = $ok -and !($_ -match 'Outdated packages found:') -or ($_ -match '^\d+ '); "+
"if ($ok) { Write-Host $_ } else { Write-Warning $_ } }";
Information("Running command: {0}", command);
var settings = new ProcessSettings
{
Arguments = string.Format("-NoProfile -Command \"{0}\"", command)
};
var exitCodeWithArgument = StartProcess("powershell", settings);
if (exitCodeWithArgument != 0) {
throw new Exception("Something bad happened. Exit code: " + exitCodeWithArgument);
}
});
Task("Version")
.Does(() =>
{
var settings = new GitVersionSettings {
UpdateAssemblyInfo = true
};
var result = GitVersion(settings);
version = result.LegacySemVerPadded;
Information("LegacySemVerPadded: {0}", version);
});
Task("Build")
.IsDependentOn("Version")
.IsDependentOn("Paket Restore")
.Does(() =>
{
var settings = new MSBuildSettings {
Verbosity = Verbosity.Minimal,
Configuration = configuration
};
MSBuild("Unity.Interception.Serilog.sln", settings);
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
EnsureDirExists(outputDir);
var file = "**/bin/*/*.Tests.dll";
var settings = new XUnit2Settings {
Parallelism = ParallelismOption.None,
HtmlReport = true,
NoAppDomain = true,
XmlReport = true,
OutputDirectory = outputDir
};
XUnit2(file, settings);
});
Task("Paket Pack")
.IsDependentOn("Build")
.Does(() =>
{
var command = string.Format("./.paket/paket.exe " +
"pack " +
"include-referenced-projects " +
"minimum-from-lock-file " +
"output {0} " +
"buildplatform {1} " +
"version {2} " +
"buildconfig {3}",
outputDir, buildPlatform, version, configuration);
Information("Running command: {0}", command);
var settings = new ProcessSettings
{
Arguments = string.Format("-NoProfile -Command \"{0}\"", command)
};
var exitCodeWithArgument = StartProcess("powershell", settings);
if (exitCodeWithArgument != 0) {
throw new Exception("Something bad happened. Exit code: " + exitCodeWithArgument);
}
});
Task("Default")
.IsDependentOn("Paket Pack")
.IsDependentOn("Test")
.IsDependentOn("Paket Outdated");
RunTarget(target);