-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.cake
155 lines (126 loc) · 4.87 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#addin "Newtonsoft.Json"
#addin "Cake.Powershell"
#addin "Cake.Incubator"
#tool "nuget:?package=xunit.runner.console&version=2.3.0"
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.8.0"
#tool "nuget:?package=GitVersion.CommandLine"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument<string>("target", "Default");
var configuration = Argument<string>("configuration", "Debug");
var name = Argument<string>("name", "Fluency");
var verbosity = Argument<string>("verbosity", "Minimal");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var solutionDir = Directory("./");
var solutionFile = solutionDir + File("Fluency.NET.sln");
var buildDir = solutionDir + Directory("bin") + Directory(configuration);
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
var settings = new DotNetCoreCleanSettings
{
Configuration = configuration
};
DotNetCoreClean(solutionFile, settings);
});
Task("Update-Version")
.Description("Calculate the version number and update assembly version files.")
.Does(() =>
{
try
{
var assemblyInfoFile = Directory("./src/Fluency") + File("Properties/AssemblyVersionInfo.cs");
if (!FileExists(assemblyInfoFile))
{
Information("Assembly version file does not exist : " + assemblyInfoFile.Path);
CopyFile("./src/AssemblyVersionInfo.template.cs", assemblyInfoFile);
}
GitVersion(new GitVersionSettings {
NoFetch = false,
OutputType = GitVersionOutput.BuildServer,
UpdateAssemblyInfo = true,
UpdateAssemblyInfoFilePath = assemblyInfoFile });
}
catch (Exception ex) {
Information(ex.ToString());
// Assume that we might be in a pull request build which cannot have the version calculated
}
});
Task("Restore-NuGet-Packages")
.Does(() =>
{
DotNetCoreRestore(solutionFile);
NuGetRestore(solutionFile);
});
Task("Pack-Nuget")
.Does(() =>
{
var nugetPackageDir = Directory("./artifacts");
EnsureDirectoryExists(nugetPackageDir);
var version = GitVersion();
var settings = new DotNetCorePackSettings
{
ArgumentCustomization = args=>args.Append("/p:PackageVersion=" + version.NuGetVersionV2),
Configuration = configuration,
OutputDirectory = nugetPackageDir,
NoRestore = true,
IncludeSymbols = true
};
DotNetCorePack("src/Fluency/Fluency.csproj", settings);
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.IsDependentOn("Update-Version")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration
};
DotNetCoreBuild("./Fluency.NET.sln", settings);
});
Task("Run-Unit-Tests")
.Does(() =>
{
var testAssemblies = GetFiles("./test/**/*.csproj");
// Disable parallel test runs due to static configuration in Fluency
var netCoreTestSettings = new DotNetCoreTestSettings() {
ArgumentCustomization = args => args.Append("-p:ParallelizeTestCollections=false"),
Configuration = configuration,
NoBuild = true,
NoRestore = true
};
var netCoreXunitTestSettings = new XUnit2Settings {
Parallelism = ParallelismOption.None,
HtmlReport = false,
UseX86 = true
};
DotNetCoreTest(netCoreTestSettings, "./test/Fluency.Net.Standard.Tests/Fluency.Net.Standard.Tests.csproj", netCoreXunitTestSettings);
var netStandardXunitSettings = new XUnit2Settings {
Parallelism = ParallelismOption.None,
HtmlReport = false,
NoAppDomain = true,
UseX86 = true
};
DotNetCoreTest(netCoreTestSettings, "./test/Fluency.Net.Framework.40.Tests/Fluency.Net.Framework.40.Tests.csproj", netCoreXunitTestSettings);
DotNetCoreTest(netCoreTestSettings, "./test/Fluency.Net.Framework.461.Tests/Fluency.Net.Framework.461.Tests.csproj", netCoreXunitTestSettings);
DotNetCoreTest(netCoreTestSettings, "./test/SampleApplication.Tests/SampleApplication.Tests.csproj", netCoreXunitTestSettings);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Build")
.IsDependentOn("Run-Unit-Tests");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);