forked from fluentassertions/fluentassertions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
128 lines (109 loc) · 4.72 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
#tool "nuget:?package=xunit.runner.console&version=2.3.0-beta5-build3769"
#tool "nuget:?package=nunit.runners&version=2.6.4"
#tool "nuget:?package=nunit.consolerunner&version=3.7.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=Machine.Specifications.Runner.Console&version=0.9.3"
#tool "nuget:?package=GitVersion.CommandLine"
//////////////////////////////////////////////////////////////////////
// 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/NSpec/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/NSpec/lib/net451/NSpec.dll", "./tools/nspec.2.0.1/NSpec/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();
NuGetRestore("./FluentAssertions.sln", new NuGetRestoreSettings
{
NoCache = true,
Verbosity = NuGetVerbosity.Detailed,
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 { });
DotNetCoreTool("./Tests/NetCore.Specs/NetCore.Specs.csproj", "xunit", "-configuration debug");
DotNetCoreTool("./Tests/NetCore20.Specs/NetCore.Specs20.csproj", "xunit", "-configuration debug");
XUnit2("./Tests/TestFrameworks/XUnit.Net45.Specs/**/bin/" + configuration + "/*.Specs.dll", new XUnit2Settings { });
XUnit2("./Tests/TestFrameworks/XUnit2.Net45.Specs/**/bin/" + configuration + "/*.Specs.dll", new XUnit2Settings { });
NUnit("./Tests/TestFrameworks/NUnit2.Net45.Specs/**/bin/" + configuration + "/*.Specs.dll", new NUnitSettings { NoResults = true });
NUnit3("./Tests/TestFrameworks/NUnit3.Net45.Specs/**/bin/" + configuration + "/*.Specs.dll", new NUnit3Settings { NoResults = true });
StartProcess(Context.Tools.Resolve("nspec.1.*/**/NSpecRunner.exe"), "./Tests/TestFrameworks/NSpec.Net45.Specs/bin/" + configuration + "/NSpec.Specs.dll");
StartProcess(Context.Tools.Resolve("nspec.2.*/**/NSpecRunner.exe"), "./Tests/TestFrameworks/NSpec2.Net45.Specs/bin/" + configuration + "/NSpec2.Specs.dll");
StartProcess(Context.Tools.Resolve("nspec.3.*/**/NSpecRunner.exe"), "./Tests/TestFrameworks/NSpec3.Net45.Specs/bin/" + configuration + "/NSpec3.Specs.dll");
StartProcess(Context.Tools.Resolve("mspec-clr4.exe"), "./Tests/TestFrameworks/MSpec.Net45.Specs/bin/" + configuration + "/MSpec.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);