-
Notifications
You must be signed in to change notification settings - Fork 36
/
csharp.cake
154 lines (130 loc) · 4.92 KB
/
csharp.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
// Install addins.
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Coveralls&version=0.7.0"
// Install tools.
#tool "nuget:https://api.nuget.org/v3/index.json?package=gitreleasemanager&version=0.7.0"
#tool "nuget:https://api.nuget.org/v3/index.json?package=GitVersion.CommandLine&version=3.6.2"
#tool "nuget:https://api.nuget.org/v3/index.json?package=coveralls.io&version=1.3.4"
#tool "nuget:https://api.nuget.org/v3/index.json?package=OpenCover&version=4.6.519"
#tool "nuget:https://api.nuget.org/v3/index.json?package=ReportGenerator&version=2.4.5"
// Load other scripts.
#load "./build/parameters.cake"
//////////////////////////////////////////////////////////////////////
// PARAMETERS
//////////////////////////////////////////////////////////////////////
BuildParameters parameters = BuildParameters.GetParameters(Context);
var publishingError = false;
DotNetCoreMSBuildSettings msBuildSettings = null;
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(context =>
{
parameters.Initialize(context);
Information("Building version {0} of Cake ({1}, {2}) using version {3} of Cake. (IsTagged: {4})",
parameters.Version.SemVersion,
parameters.Configuration,
parameters.Target,
parameters.Version.CakeVersion,
parameters.IsTagged);
var releaseNotes = string.Join("\n", parameters.ReleaseNotes.Notes.ToArray()).Replace("\"", "\"\"");
msBuildSettings = new DotNetCoreMSBuildSettings()
.WithProperty("Version", parameters.Version.SemVersion)
.WithProperty("AssemblyVersion", parameters.Version.Version)
.WithProperty("FileVersion", parameters.Version.Version)
.WithProperty("PackageReleaseNotes", string.Concat("\"", releaseNotes, "\""));
if (!parameters.IsRunningOnWindows)
{
var frameworkPathOverride = new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath + "/";
// Use FrameworkPathOverride when not running on Windows.
Information("Build will use FrameworkPathOverride={0} since not building on Windows.", frameworkPathOverride);
msBuildSettings.WithProperty("FrameworkPathOverride", frameworkPathOverride);
}
});
Teardown(context =>
{
Information("Finished running tasks.");
});
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectories(parameters.Paths.Directories.ToClean);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore("./src/Cake.sln", new DotNetCoreRestoreSettings
{
Verbosity = DotNetCoreVerbosity.Minimal,
Sources = new [] {
"https://www.myget.org/F/xunit/api/v3/index.json",
"https://api.nuget.org/v3/index.json"
},
MSBuildSettings = msBuildSettings
});
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
// Build the solution.
var path = MakeAbsolute(new DirectoryPath("./src/Cake.sln"));
DotNetCoreBuild(path.FullPath, new DotNetCoreBuildSettings()
{
Configuration = parameters.Configuration,
NoRestore = true,
MSBuildSettings = msBuildSettings
});
});
Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
var projects = GetFiles("./src/**/*.Tests.csproj");
foreach (var project in projects)
{
// .NET Core
DotNetCoreTest(project.ToString(), new DotNetCoreTestSettings
{
Framework = "netcoreapp2.0",
NoBuild = true,
NoRestore = true,
Configuration = parameters.Configuration
});
DotNetCoreTest(project.ToString(), new DotNetCoreTestSettings
{
Framework = framework,
NoBuild = true,
NoRestore = true,
Configuration = parameters.Configuration
});
}
});
Task("Copy-Files")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
{
// .NET Core
DotNetCorePublish("./src/Cake", new DotNetCorePublishSettings
{
Framework = "netcoreapp2.0",
NoRestore = true,
Configuration = parameters.Configuration,
OutputDirectory = parameters.Paths.Directories.ArtifactsBinNetCore,
MSBuildSettings = msBuildSettings
});
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Package")
.IsDependentOn("Copy-Files")
Task("Default")
.IsDependentOn("Package");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(parameters.Target);