-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.cake
91 lines (77 loc) · 3.11 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
#tool nuget:?package=ReportGenerator&version=4.1.10
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "default");
var configuration = Argument("configuration", "Release");
var version = XmlPeek(File("./build/common.props"), "/Project/PropertyGroup/Version/text()");
var sln = "./Cassette.sln";
var distDir = "./dist";
var distDirFullPath = MakeAbsolute(Directory($"{distDir}")).FullPath;
var publishDir = "./publish";
var publishDirFullPath = MakeAbsolute(Directory($"{publishDir}")).FullPath;
var framework = "netstandard2.0";
var logger = Environment.GetEnvironmentVariable("TF_BUILD") == "True" ? $"-l:trx --results-directory {publishDirFullPath}" : "-l:console;verbosity=normal";
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(ctx =>
{
Information($"Building Cassette {version}");
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("clean").Does(() =>
{
CreateDirectory(distDir);
CleanDirectories(distDir);
CleanDirectories(publishDir);
CleanDirectories($"./**/obj/{framework}");
CleanDirectories(string.Format("./**/obj/{0}", configuration));
CleanDirectories(string.Format("./**/bin/{0}", configuration));
});
Task("build").Does(() =>
{
DotNetCoreBuild(".", new DotNetCoreBuildSettings
{
Configuration = configuration,
Verbosity = DotNetCoreVerbosity.Minimal
});
});
Task("test").Does(() =>
{
DotNetCoreTest("./test/Cassette.Tests", new DotNetCoreTestSettings
{
Configuration = configuration,
ArgumentCustomization = args => args.Append(logger)
.Append("/p:AltCover=true")
.Append("/p:AltCoverForce=true")
.Append("/p:AltCoverCallContext=[Fact]|[Theory]")
.Append("/p:AltCoverAssemblyFilter=Cassette.Tests|AspNetCore.HttpClientFactory.QuickStart|xunit.runner")
.Append($"/p:AltCoverXmlReport={publishDirFullPath}/coverage.xml")
});
});
Task("report-coverage").Does(() =>
{
ReportGenerator($"{publishDir}/coverage.xml", $"{publishDir}/coverage", new ReportGeneratorSettings
{
ReportTypes = new[] { ReportGeneratorReportType.Cobertura, ReportGeneratorReportType.HtmlInline_AzurePipelines_Dark },
Verbosity = ReportGeneratorVerbosity.Info
});
});
Task("pack").Does(() =>
{
NuGetPack("./src/Cassette/Cassette.nuspec", new NuGetPackSettings
{
OutputDirectory = distDir,
Version = version
});
});
Task("default")
.IsDependentOn("clean")
.IsDependentOn("build")
.IsDependentOn("test")
.IsDependentOn("report-coverage")
.IsDependentOn("pack");
RunTarget(target);