-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.cake
90 lines (74 loc) · 2.79 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
using System;
// Parameters.
var projectName = "PCLMock";
var versionMajorMinorPatch = "5.1.3";
var versionSuffix = "";
var semanticVersion = versionMajorMinorPatch + versionSuffix;
var version = versionMajorMinorPatch + ".0" + versionSuffix;
var configuration = EnvironmentVariable("CONFIGURATION") ?? "Release";
var nugetSource = "https://www.nuget.org/api/v2/package";
// To push to NuGet, run with: & {$env:NUGET_API_KEY="$KEY"; ./build.ps1}
var nugetApiKey = EnvironmentVariable("NUGET_API_KEY");
// Paths.
var srcDir = Directory("Src");
var solution = srcDir + File(projectName + ".sln");
Setup(context => Information("Building {0} version {1}.", projectName, version));
Teardown(context => Information("Build {0} finished.", version));
Task("Clean")
.Does(() => DotNetCoreClean(solution));
Task("Pre-Build")
.Does(
() =>
{
});
Task("Build")
.IsDependentOn("Pre-Build")
.Does(
() =>
{
var msBuildSettings = new DotNetCoreMSBuildSettings();
msBuildSettings.Properties["Version"] = new string[]
{
version
};
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration,
MSBuildSettings = msBuildSettings,
};
DotNetCoreBuild(solution, settings);
});
Task("Test")
.IsDependentOn("Build")
.Does(
() =>
{
var testProject = srcDir + Directory("PCLMock.UnitTests") + File("PCLMock.UnitTests.csproj");
DotNetCoreTest(testProject);
});
Task("Push")
.IsDependentOn("Test")
.WithCriteria(nugetApiKey != null)
.Does(
() =>
{
var settings = new DotNetCoreNuGetPushSettings
{
ApiKey = nugetApiKey,
Source = nugetSource,
};
var nuGetPackages = new []
{
srcDir + Directory("PCLMock/bin") + Directory(configuration) + File("PCLMock." + semanticVersion + ".nupkg"),
srcDir + Directory("PCLMock.CodeGeneration/bin") + Directory(configuration) + File("PCLMock.CodeGeneration." + semanticVersion + ".nupkg"),
srcDir + Directory("PCLMock.CodeGeneration.Console/bin") + Directory(configuration) + File("PCLMock.CodeGeneration.Console." + semanticVersion + ".nupkg"),
srcDir + Directory("PCLMock.CodeGeneration.SourceGenerator/bin") + Directory(configuration) + File("PCLMock.CodeGeneration.SourceGenerator." + semanticVersion + ".nupkg"),
};
foreach (var nuGetPackage in nuGetPackages)
{
DotNetCoreNuGetPush(nuGetPackage, settings);
}
});
Task("Default")
.IsDependentOn("Push");
RunTarget(Argument("target", "Default"));