forked from dhei/azure-mobile-apps-net-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
76 lines (64 loc) · 2.26 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
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var nugetVersion = Argument("nugetVersion", EnvironmentVariable("NUGET_VERSION") ?? "1.0.0");
var baseVersion = nugetVersion.Contains("-")
? nugetVersion.Substring(0, nugetVersion.IndexOf("-"))
: nugetVersion;
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("Build")
.Does(() =>
{
Information("Building with NuGet version: {0}", nugetVersion);
Information("Building with assembly version: {0}", baseVersion);
MSBuild("./Microsoft.Azure.Mobile.Client.sln", c => c
.SetConfiguration(configuration)
.EnableBinaryLogger("./output/build.binlog")
.WithRestore()
.WithTarget("Build")
.WithProperty("PackageOutputPath", MakeAbsolute((DirectoryPath)"./output/").FullPath)
.WithProperty("PackageVersion", nugetVersion)
.WithProperty("Version", baseVersion));
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = "Release",
NoBuild = true,
NoRestore = true,
ResultsDirectory = "./output/unittests-results"
};
var failCount = 0;
var projectFiles = GetFiles("./unittests/**/*.csproj");
foreach(var file in projectFiles)
{
settings.Logger = "trx;LogFileName=" + file.GetFilenameWithoutExtension() + "-Results.trx";
try
{
DotNetCoreTest(file.FullPath, settings);
}
catch
{
failCount++;
}
}
if (failCount > 0)
throw new Exception($"There were {failCount} test failures.");
});
///////////////////////////////////////////////////////////////////////////////
// ENTRYPOINTS
///////////////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Build")
.IsDependentOn("Test");
Task("ci")
.IsDependentOn("Build")
.IsDependentOn("Test");
RunTarget(target);