-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.cake
More file actions
129 lines (104 loc) · 3.94 KB
/
build.cake
File metadata and controls
129 lines (104 loc) · 3.94 KB
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
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var verbosity = Argument<Verbosity>("verbosity", Verbosity.Minimal);
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
var baseName = "NUnitTestOrdering";
var buildDir = Directory("./build") + Directory(configuration);
var assemblyInfoFile = Directory($"./src/{baseName}/Properties") + File("AssemblyInfo.cs");
var dotCoverResultFile = buildDir + File("CoverageResults.dcvr");
var nuspecPath = File($"./nuget/{baseName}.nuspec");
var testResultsFile = buildDir + File("NUnitTestResults.trx");
var mainAssemblyVersion = (string) null;
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() => {
CleanDirectory(buildDir);
CleanDirectories("./src/**/bin");
CleanDirectories("./src/**/obj");
});
Task("Rebuild")
.IsDependentOn("Clean")
.IsDependentOn("Build");
Task("Restore-NuGet-Packages")
.Does(() => {
NuGetRestore($"./{baseName}.sln");
Information("Running NuGet restore for tests");
// For tests, we require additional packages
NuGetRestore($"./src/{baseName}.Tests/Support/NUnitTestVersions/packages.config", new NuGetRestoreSettings {
PackagesDirectory = Directory("./packages") // Required when not restoring solution
});
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() => {
DotNetCoreBuild($"./{baseName}.sln", new DotNetCoreBuildSettings { Configuration = configuration } );
});
Task("Test")
.IsDependentOn("Build")
.Description("Run all unit tests - under code coverage")
.Does(() =>
DotNetCoreTest($"./{baseName}.sln", new DotNetCoreTestSettings {
ArgumentCustomization = (args) => args.AppendQuoted($"--logger:trx;LogFileName={testResultsFile}")
.Append("--logger:\"console;verbosity=normal;noprogress=true\"")
}));
Task("NuGet-Test")
.IsDependentOn("Test")
.Description("Run all unit tests in preperation nupack");
Task("NuGet-Git-UpdateAssemblyInfo")
.Does(() => {
GitVersion(); // TODO: use this for nuspec
});
Task("NuGet-Get-Assembly-Version")
.IsDependentOn("NuGet-Git-UpdateAssemblyInfo")
.Does(() => {
mainAssemblyVersion = ParseAssemblyInfo(assemblyInfoFile).AssemblyInformationalVersion;
if (mainAssemblyVersion == null){
throw new CakeException($"Unable to find version for assembly via {assemblyInfoFile}");
}
});
Task("NuGet-Pack")
.IsDependentOn("Build")
.IsDependentOn("NuGet-Get-Assembly-Version")
.Description("Packs up a NuGet package")
.Does(() => {
NuGetPack(
nuspecPath,
new NuGetPackSettings() {
OutputDirectory = buildDir,
Version = mainAssemblyVersion
}
);
});
Task("AppVeyor-Test")
.IsDependentOn("Clean")
.IsDependentOn("Test")
.Does(() => {
var jobId = EnvironmentVariable("APPVEYOR_JOB_ID");
var resultsType = "nunit3";
var wc = new System.Net.WebClient();
var url = $"https://ci.appveyor.com/api/testresults/{resultsType}/{jobId}";
var fullTestResultsPath = MakeAbsolute(testResultsFile).FullPath;
Information("Uploading test results from {0} to {1}", fullTestResultsPath, url);
wc.UploadFile(url, fullTestResultsPath);
});
Task("AppVeyor")
.IsDependentOn("AppVeyor-Test")
.IsDependentOn("NuGet-Pack")
;
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("None");
Task("Default")
.IsDependentOn("Test");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);