forked from dotnet/BenchmarkDotNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
132 lines (115 loc) · 4 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
// ARGUMENTS
var target = Argument("Target", "Default");
var configuration = Argument("Configuration", "Release");
var skipTests = Argument("SkipTests", false);
// GLOBAL VARIABLES
var artifactsDirectory = Directory("./artifacts");
var solutionFile = "./BenchmarkDotNet.sln";
var integrationTestsProjectPath = "./tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj";
var isRunningOnWindows = IsRunningOnWindows();
var IsOnAppVeyorAndNotPR = AppVeyor.IsRunningOnAppVeyor && !AppVeyor.Environment.PullRequest.IsPullRequest;
var msBuildSettings = new DotNetCoreMSBuildSettings
{
MaxCpuCount = 1
};
Setup(_ =>
{
if(!isRunningOnWindows)
{
StartProcess("mono", new ProcessSettings { Arguments = "--version" });
var frameworkPathOverride = new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath;
// setup correct version
frameworkPathOverride = System.IO.Path.Combine(System.IO.Directory.GetParent(frameworkPathOverride).FullName, "4.6-api/");
Information("Build will use FrameworkPathOverride={0} since not building on Windows.", frameworkPathOverride);
msBuildSettings.WithProperty("FrameworkPathOverride", frameworkPathOverride);
}
msBuildSettings.WithProperty("UseSharedCompilation", "false");
});
Task("Clean")
.Does(() =>
{
CleanDirectory(artifactsDirectory);
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(solutionFile);
});
Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
var path = MakeAbsolute(new DirectoryPath(solutionFile));
DotNetCoreBuild(path.FullPath, new DotNetCoreBuildSettings
{
Configuration = configuration,
NoRestore = true,
DiagnosticOutput = true,
MSBuildSettings = msBuildSettings,
Verbosity = DotNetCoreVerbosity.Minimal
});
});
Task("FastTests")
.IsDependentOn("Build")
.WithCriteria(!skipTests)
.Does(() =>
{
string[] targetVersions = IsRunningOnWindows() ?
new []{"net46", "netcoreapp2.1"}
:
new []{"netcoreapp2.1"};
foreach(var version in targetVersions)
{
DotNetCoreTool("./tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj", "xunit", GetTestSettingsParameters(version));
}
});
Task("SlowTestsNet46")
.IsDependentOn("Build")
.WithCriteria(!skipTests && isRunningOnWindows)
.Does(() =>
{
DotNetCoreTool(integrationTestsProjectPath, "xunit", GetTestSettingsParameters("net46"));
});
Task("SlowTestsNetCore2")
.IsDependentOn("Build")
.WithCriteria(!skipTests)
.Does(() =>
{
DotNetCoreTool(integrationTestsProjectPath, "xunit", GetTestSettingsParameters("netcoreapp2.1"));
});
Task("Pack")
.IsDependentOn("Build")
.WithCriteria((IsOnAppVeyorAndNotPR || string.Equals(target, "pack", StringComparison.OrdinalIgnoreCase)) && isRunningOnWindows)
.Does(() =>
{
var settings = new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = artifactsDirectory
};
var projects = GetFiles("./src/**/*.csproj");
foreach(var project in projects.Where(p => !p.FullPath.Contains("Disassembler")))
{
DotNetCorePack(project.FullPath, settings);
}
});
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("FastTests")
.IsDependentOn("SlowTestsNetCore2")
.IsDependentOn("SlowTestsNet46")
.IsDependentOn("Pack");
RunTarget(target);
// HELPERS
private string GetTestSettingsParameters(string tfm)
{
var settings = $"-configuration {configuration} -parallel none -nobuild -framework {tfm}";
if(string.Equals("netcoreapp2.1", tfm, StringComparison.OrdinalIgnoreCase))
{
settings += " --fx-version 2.1.0-preview1-26216-03";
}
return settings;
}