forked from OmniSharp/csharp-language-server-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
155 lines (138 loc) · 4.71 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
#tool "nuget:?package=GitVersion.CommandLine"
#tool "nuget:?package=xunit.runner.console"
#tool "nuget:?package=JetBrains.dotCover.CommandLineTools"
#load "tasks/variables.cake";
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var artifacts = new DirectoryPath("./artifacts").MakeAbsolute(Context.Environment);
Task("Clean")
.Does(() =>
{
EnsureDirectoryExists(artifacts);
CleanDirectory(artifacts);
});
Task("Restore (Unix)")
.WithCriteria(IsRunningOnUnix)
.Does(() =>
{
MSBuild("./LSP.sln", settings => settings.SetConfiguration(configuration).WithTarget("Restore"));
});
Task("Restore (Windows)")
.WithCriteria(IsRunningOnWindows)
.Does(() =>
{
DotNetCoreRestore();
});
Task("Restore")
.IsDependentOn("Restore (Unix)")
.IsDependentOn("Restore (Windows)");
Task("Build")
.IsDependentOn("Restore")
.DoesForEach(GetFiles("src/**/*.csproj").Concat(GetFiles("test/**/*.csproj")), (project) =>
{
MSBuild(project, settings =>
settings
.SetConfiguration(configuration)
.WithTarget("Build"));
});
Task("TestSetup")
.Does(() => {
CleanDirectory(artifacts + "/tests");
CleanDirectory(artifacts + "/coverage");
EnsureDirectoryExists(artifacts + "/tests");
EnsureDirectoryExists(artifacts + "/coverage");
});
Task("Test (No Coverage)")
.WithCriteria(IsRunningOnUnix)
.WithCriteria(false) // TODO: Make work on travis
.IsDependentOn("TestSetup")
.IsDependentOn("Build")
.DoesForEach(GetFiles("test/*/*.csproj"), (testProject) =>
{
DotNetCoreTest(
testProject.GetDirectory().FullPath,
new DotNetCoreTestSettings() {
NoBuild = true,
Framework = "netcoreapp2.0",
EnvironmentVariables = GitVersionEnvironmentVariables,
});
});
Task("Test (Coverage)")
.WithCriteria(IsRunningOnWindows)
.IsDependentOn("TestSetup")
.IsDependentOn("Build")
.DoesForEach(GetFiles("test/*/*.csproj"), (testProject) =>
{
DotCoverCover(tool => {
tool.DotNetCoreTool(
testProject.GetDirectory().FullPath,
"xunit",
new ProcessArgumentBuilder()
.AppendSwitchQuoted("-xml", string.Format("{0}/tests/{1}.xml", artifacts, testProject.GetFilenameWithoutExtension()))
.AppendSwitch("-configuration", configuration)
.Append("-noshadow"),
new DotNetCoreToolSettings() {
EnvironmentVariables = GitVersionEnvironmentVariables,
});
},
artifacts + "/coverage/coverage-"+ testProject.GetFilenameWithoutExtension() + ".dcvr",
new DotCoverCoverSettings() {
TargetWorkingDir = testProject.GetDirectory(),
WorkingDirectory = testProject.GetDirectory(),
EnvironmentVariables = GitVersionEnvironmentVariables,
}
.WithFilter("+:OmniSharp.*")
);
})
.Finally(() => {
DotCoverMerge(
GetFiles(artifacts + "/coverage/*.dcvr"),
artifacts + "/coverage/coverage.dcvr"
);
DotCoverReport(
artifacts + "/coverage/coverage.dcvr",
new FilePath(artifacts + "/coverage/coverage.html"),
new DotCoverReportSettings {
ReportType = DotCoverReportType.HTML
}
);
DotCoverReport(
artifacts + "/coverage/coverage.dcvr",
new FilePath(artifacts + "/coverage/coverage.xml"),
new DotCoverReportSettings {
ReportType = DotCoverReportType.DetailedXML
}
);
var withBom = System.IO.File.ReadAllText(artifacts + "/coverage/coverage.xml");
System.IO.File.WriteAllText(artifacts + "/coverage/coverage.xml", withBom.Replace(_byteOrderMarkUtf8, ""));
});
Task("Test")
.IsDependentOn("Test (Coverage)")
.IsDependentOn("Test (No Coverage)");
Task("Pack")
.WithCriteria(IsRunningOnWindows) // TODO: Make work on travis
.IsDependentOn("Build")
.Does(() => EnsureDirectoryExists(artifacts + "/nuget"))
.DoesForEach(GetFiles("src/*/*.csproj"), (project) => {
DotNetCorePack(project.FullPath, new DotNetCorePackSettings
{
NoBuild = true,
IncludeSymbols = true,
Configuration = configuration,
EnvironmentVariables = GitVersionEnvironmentVariables,
OutputDirectory = artifacts + "/nuget"
});
});
Task("GitVersion")
.Does(() => {
GitVersion(new GitVersionSettings() {
OutputType = GitVersionOutput.BuildServer
});
});
Task("Default")
.IsDependentOn("GitVersion")
.IsDependentOn("Clean")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Pack");
RunTarget(target);