-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDotNet.cake
114 lines (104 loc) · 2.81 KB
/
DotNet.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
public static class DotNet {
public static string Execute(string arguments)
{
var process = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
{
FileName = "dotnet",
Arguments = arguments,
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
});
return process.StandardOutput.ReadToEnd().Trim();
}
}
Task("dotnet-version")
.Does(() =>
{
Information($".NET Core version: {DotNet.Execute("--version")}");
Information($"Code build: {Build.Version}");
});
Task("dotnet-clean")
.Does(() =>
{
DotNetCoreClean(".", new DotNetCoreCleanSettings
{
Configuration = Build.Configuration,
Verbosity = DotNetCoreVerbosity.Minimal
});
});
Task("dotnet-restore")
.Does(() =>
{
Information(NuGet.Execute("sources list"));
Information("");
DotNetCoreRestore(new DotNetCoreRestoreSettings
{
Verbosity = DotNetCoreVerbosity.Minimal
});
});
Task("dotnet-build")
.Does(() =>
{
Information($"Building version {Build.Version} ...");
DotNetCoreBuild(".", new DotNetCoreBuildSettings
{
Configuration = Build.Configuration,
MSBuildSettings = new DotNetCoreMSBuildSettings()
.SetVersion(Build.Version),
NoRestore = true,
Verbosity = DotNetCoreVerbosity.Minimal
});
});
Task("dotnet-unit-tests")
.DoesForEach(() => Build.UnitTests, project =>
{
Information($"Running unit tests in '{project.Path}' ...");
DotNetCoreTest(project.Path, new DotNetCoreTestSettings
{
Configuration = Build.Configuration,
NoBuild = true,
NoRestore = true,
Verbosity = DotNetCoreVerbosity.Normal,
ArgumentCustomization = args => args
.Append("/p:CollectCoverage=true")
.Append("/p:CoverletOutput=TestResults/")
.Append("/p:CoverletOutputFormat=lcov")
});
});
Task("dotnet-integration-tests")
.DoesForEach(() => Build.IntegrationTests, project =>
{
Information($"Running integration tests in '{project.Path}' ...");
DotNetCoreTest(project.Path, new DotNetCoreTestSettings
{
Configuration = Build.Configuration,
NoBuild = true,
NoRestore = true,
Verbosity = DotNetCoreVerbosity.Normal
});
});
Task("dotnet-publish")
.Does(() =>
{
Information($"Deleting folder '{Build.Folders.Publish}' ...");
if (DirectoryExists(Build.Folders.Publish))
DeleteDirectory(Build.Folders.Publish, new DeleteDirectorySettings
{
Recursive = true
});
})
.DoesForEach(() => Build.ToBePublished, project =>
{
var output = System.IO.Path.Combine(Build.Folders.Publish, project.Name);
Information($"Publishing project '{project.Path}' to '{output}'...");
DotNetCorePublish(project.Path, new DotNetCorePublishSettings
{
Configuration = Build.Configuration,
DiagnosticOutput = false,
NoBuild = true,
NoRestore = true,
OutputDirectory = output,
Verbosity = DotNetCoreVerbosity.Normal
});
});