forked from craftworkgames/MonoGame.Extended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
96 lines (79 loc) · 2.88 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
#tool nuget:?package=vswhere
#tool nuget:?package=NUnit.Runners&version=2.6.4
#tool nuget:?package=GitVersion.CommandLine&prerelease
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var solution = "./Source/MonoGame.Extended.sln";
var vsLatest = VSWhereLatest();
var msBuildPath = vsLatest?.CombineWithFilePath("./MSBuild/15.0/Bin/amd64/MSBuild.exe");
var gitVersion = GitVersion();
Information($"##teamcity[buildNumber '{gitVersion.NuGetVersion}']");
TaskSetup(context => Information($"##teamcity[blockOpened name='{context.Task.Name}']"));
TaskTeardown(context => Information($"##teamcity[blockClosed name='{context.Task.Name}']"));
Task("Restore")
.Does(() =>
{
Information("##teamcity[progressMessage 'Restoring packages...']");
DotNetCoreRestore(solution);
});
Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
Information("##teamcity[progressMessage 'Building solution...']");
var buildSettings = new DotNetCoreBuildSettings
{
Configuration = configuration,
ArgumentCustomization = args => args.Append($"/p:Version={gitVersion.AssemblySemVer}")
};
// first we build the Extended Content Pipeline DLL as a workaround to issue #495
DotNetCoreBuild($"./Source/MonoGame.Extended.Content.Pipeline/MonoGame.Extended.Content.Pipeline.csproj", buildSettings);
// then we can build the rest of the solution
DotNetCoreBuild(solution, buildSettings);
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
Information("##teamcity[progressMessage 'Running tests...']");
var testRuns = 0;
var failedRuns = 0;
var testProjects = GetFiles($"./Source/Tests/**/*.Tests.csproj");
foreach (var project in testProjects)
{
try
{
testRuns++;
Information("Test Run {0} of {1} - {2}", testRuns, testProjects.Count, project.GetFilenameWithoutExtension());
DotNetCoreTest(project.FullPath);
}
catch
{
failedRuns++;
}
}
if(failedRuns > 0)
throw new Exception($"{failedRuns} of {testRuns} test runs failed.");
});
Task("Pack")
.IsDependentOn("Test")
.Does(() =>
{
Information("##teamcity[progressMessage 'Packing packages...']");
var artifactsDirectory = "./artifacts";
CreateDirectory(artifactsDirectory);
CleanDirectory(artifactsDirectory);
foreach (var project in GetFiles($"./Source/MonoGame.Extended*/*.csproj"))
{
DotNetCorePack(project.FullPath, new DotNetCorePackSettings
{
Configuration = configuration,
IncludeSymbols = true,
OutputDirectory = artifactsDirectory,
ArgumentCustomization = args => args.Append($"/p:Version={gitVersion.NuGetVersion}")
});
}
});
Task("Default")
.IsDependentOn("Pack");
RunTarget(target);