forked from fluentassertions/fluentassertions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
134 lines (115 loc) · 4.98 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
#tool "nuget:?package=xunit.runner.console&version=2.4.0"
#tool "nuget:?package=nspec&version=1.0.13"
#tool "nuget:?package=nspec&version=2.0.1"
#tool "nuget:?package=nspec&version=3.1.0"
#tool "nuget:?package=nunit.runners&version=2.7.0"
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var toolpath = Argument("toolpath", @"");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var buildDir = Directory("./Artifacts") + Directory(configuration);
GitVersion gitVersion = null;
if (!FileExists("./tools/NSpec.2.0.1/tools/net451/NSpec.dll"))
{
// NSpec2.0.1 does not have NSpec.dll in the test runner directory, which crashes the test runner.
CopyFile("./tools/NSpec.2.0.1/lib/net451/NSpec.dll", "./tools/NSpec.2.0.1/tools/net451/NSpec.dll");
}
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
});
Task("GitVersion").Does(() => {
gitVersion = GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
});
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(new DotNetCoreRestoreSettings
{
NoCache = true,
ConfigFile = "./nuget.config",
Verbosity = DotNetCoreVerbosity.Normal
});
NuGetRestore("./FluentAssertions.sln", new NuGetRestoreSettings
{
NoCache = true,
ConfigFile = "./nuget.config",
Verbosity = NuGetVerbosity.Normal,
ToolPath = "./build/nuget.exe"
});
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.IsDependentOn("GitVersion")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./FluentAssertions.sln", settings => {
settings.ToolPath = String.IsNullOrEmpty(toolpath) ? settings.ToolPath : toolpath;
settings.ToolVersion = MSBuildToolVersion.VS2017;
settings.PlatformTarget = PlatformTarget.MSIL;
settings.SetConfiguration(configuration);
});
}
else
{
// Use XBuild
XBuild("./FluentAssertions.sln", settings =>
settings.SetConfiguration(configuration));
}
});
Task("Run-Unit-Tests")
.Does(() =>
{
XUnit2("./Tests/Net45.Specs/bin/Debug/**/*.Specs.dll", new XUnit2Settings { });
XUnit2("./Tests/Net47.Specs/bin/Debug/**/*.Specs.dll", new XUnit2Settings { });
DotNetCoreTest("./Tests/NetCore.Specs/NetCore.Specs.csproj", new DotNetCoreTestSettings { Configuration = "Debug" });
DotNetCoreTest("./Tests/NetStandard13.Specs/NetStandard13.Specs.csproj", new DotNetCoreTestSettings { Configuration = "Debug" });
DotNetCoreTest("./Tests/NetCore20.Specs/NetCore20.Specs.csproj", new DotNetCoreTestSettings { Configuration = "Debug" });
DotNetCoreTest("./Tests/TestFrameworks/MSpec.Specs/MSpec.Specs.csproj", new DotNetCoreTestSettings { Configuration = "Debug" });
DotNetCoreTest("./Tests/TestFrameworks/MSTestV2.Specs/MSTestV2.Specs.csproj", new DotNetCoreTestSettings { Configuration = "Debug" });
DotNetCoreTest("./Tests/TestFrameworks/NUnit3.Specs/NUnit3.Specs.csproj", new DotNetCoreTestSettings { Configuration = "Debug" });
DotNetCoreTest("./Tests/TestFrameworks/XUnit2.Specs/XUnit2.Specs.csproj", new DotNetCoreTestSettings { Configuration = "Debug" });
XUnit2("./Tests/TestFrameworks/XUnit.Net45.Specs/**/bin/Debug/**/*.Specs.dll", new XUnit2Settings { });
NUnit("./Tests/TestFrameworks/NUnit2.Net45.Specs/**/bin/Debug/**/*.Specs.dll", new NUnitSettings { NoResults = true });
StartProcess(Context.Tools.Resolve("nspec.1.*/**/NSpecRunner.exe"), "./Tests/TestFrameworks/NSpec.Net45.Specs/bin/Debug/net451/NSpec.Specs.dll");
StartProcess(Context.Tools.Resolve("nspec.2.*/**/NSpecRunner.exe"), "./Tests/TestFrameworks/NSpec2.Net45.Specs/bin/Debug/net451/NSpec2.Specs.dll");
StartProcess(Context.Tools.Resolve("nspec.3.*/**/NSpecRunner.exe"), "./Tests/TestFrameworks/NSpec3.Net45.Specs/bin/Debug/net451/NSpec3.Specs.dll");
});
Task("Pack")
.IsDependentOn("GitVersion")
.Does(() =>
{
NuGetPack("./src/FluentAssertions.nuspec", new NuGetPackSettings {
OutputDirectory = "./Artifacts",
Version = gitVersion.NuGetVersionV2
});
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("GitVersion")
.IsDependentOn("Build")
.IsDependentOn("Run-Unit-Tests")
.IsDependentOn("Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);