-
Notifications
You must be signed in to change notification settings - Fork 25
/
build.cake
109 lines (92 loc) · 3.42 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
using System;
// Parameters.
var projectName = "KBCsv";
var semanticVersion = "6.0.0";
var version = semanticVersion + ".0";
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(
() =>
{
CreateAssemblyInfo(
srcDir + File("AssemblyInfoCommon.cs"),
new AssemblyInfoSettings
{
Company = "Kent Boogaart",
Product = projectName,
Copyright = "© Copyright. Kent Boogaart.",
Version = version,
FileVersion = version,
InformationalVersion = semanticVersion.ToString(),
Configuration = configuration
}
.AddCustomAttribute("NeutralResourcesLanguage", "System.Resources", "en-US"));
});
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 testProjects = new []
{
srcDir + Directory("KBCsv.UnitTests") + File("KBCsv.UnitTests.csproj"),
srcDir + Directory("KBCsv.Extensions.UnitTests") + File("KBCsv.Extensions.UnitTests.csproj"),
srcDir + Directory("KBCsv.Extensions.Data.UnitTests") + File("KBCsv.Extensions.Data.UnitTests.csproj"),
};
foreach (var testProject in testProjects)
{
DotNetCoreTest(testProject);
}
});
Task("Push")
.IsDependentOn("Test")
.WithCriteria(nugetApiKey != null)
.Does(
() =>
{
var settings = new DotNetCoreNuGetPushSettings
{
ApiKey = nugetApiKey,
Source = nugetSource,
};
var nuGetPackages = new []
{
srcDir + Directory("KBCsv/bin") + Directory(configuration) + File("KBCsv." + semanticVersion + ".nupkg"),
srcDir + Directory("KBCsv.Extensions/bin") + Directory(configuration) + File("KBCsv.Extensions." + semanticVersion + ".nupkg"),
srcDir + Directory("KBCsv.Extensions.Data/bin") + Directory(configuration) + File("KBCsv.Extensions.Data." + semanticVersion + ".nupkg"),
};
foreach (var nuGetPackage in nuGetPackages)
{
DotNetCoreNuGetPush(nuGetPackage, settings);
}
});
Task("Default")
.IsDependentOn("Push");
RunTarget(Argument("target", "Default"));