forked from torshy/echonest-sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
109 lines (97 loc) · 2.98 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
var target = Argument("Target", "Unit-Tests"); // Task to run
var configuration = Argument("Configuration", "Release"); // Build configuration (Debug/Release)
var assemblyVersion = Argument("AssemblyVersion", "0.0.0.0"); // Sets the assembly version
var assemblyFileVersion = Argument("FileVersion", "0.0.0.0"); // Sets the assembly file version
var prereleaseVersion = Argument("PrereleaseVersion", string.Empty); // Sets the assembly informational version postfix
var nugetApiKey = Argument("NuGetKey", string.Empty); // NuGet API Key
var buildDir = "./src/EchoNest-Sharp/bin/" + configuration;
var nugetPath = "./.nuget/NuGet.exe";
var nuspecsDir = @"./nuspecs";
var version = assemblyVersion + prereleaseVersion;
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
DeleteFiles(nuspecsDir + "/*.nupkg");
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(context =>
{
NuGetRestore("./EchoNest-Sharp.sln", new NuGetRestoreSettings
{
ToolPath = nugetPath
});
});
Task("Patch-Assembly-Info")
.Description("Patches the AssemblyInfo files.")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
var file = "./src/EchoNest-Sharp/Properties/AssemblyInfo.cs";
CreateAssemblyInfo(file, new AssemblyInfoSettings {
Product = "EchoNest-Sharp",
Version = assemblyVersion,
FileVersion = assemblyFileVersion,
InformationalVersion = version,
Copyright = "Copyright (c) Torstein Auensen 2014"
});
});
Task("Build")
.IsDependentOn("Patch-Assembly-Info")
.Description("Compiles the solution")
.Does(() =>
{
MSBuild("./EchoNest-Sharp.sln", s => s
.SetConfiguration(configuration)
.WithProperty("TreatWarningsAsErrors", "true")
.WithProperty("StyleCopTreatErrorsAsWarnings", "false")
.WithProperty("AllowedReferenceRelatedFileExtensions", ".pdb"));
});
Task("Unit-Tests")
.IsDependentOn("Build")
.Description("Runs all unit tests")
.Does(() =>
{
var toolPath = GetFiles("./packages/nunit.runners*/tools/**/nunit-console.exe").FirstOrDefault<FilePath>();
NUnit("./src/**/bin/" + configuration + "/*.Tests.dll", new NUnitSettings
{
ToolPath = toolPath
});
});
Task("Create-NuGet-Package")
.IsDependentOn("Unit-Tests")
.Description("Create NuGet package")
.Does(() =>
{
NuGetPack("./nuspecs/EchoNest-Sharp.nuspec", new NuGetPackSettings
{
ToolPath = nugetPath,
Version = version,
OutputDirectory = nuspecsDir,
NoPackageAnalysis = true
});
});
Task("Publish-NuGet")
.IsDependentOn("Create-NuGet-Package")
.WithCriteria(() => !string.IsNullOrWhiteSpace(nugetApiKey))
.Description("Push NuGet package to server")
.Does(() =>
{
var packages = GetFiles(nuspecsDir + "/*.nupkg");
foreach(var package in packages)
{
Information("NuGet Push - " + package);
// Push the package.
NuGetPush(package, new NuGetPushSettings
{
ToolPath = nugetPath,
ApiKey = nugetApiKey
});
}
});
Task("Publish")
.IsDependentOn("Unit-Tests")
.IsDependentOn("Publish-NuGet");
//////////////////////////////////////////////////////////////////////
RunTarget(target);