-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
115 lines (82 loc) · 3.13 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
110
111
112
113
114
115
// To create the bootstrapper, from within powershell run the following.
// Invoke-WebRequest http://cakebuild.net/bootstrapper/windows -OutFile build.ps1
//
// To execute, run the following within powershell
// ./Build.ps1 -Target "build"
// For smoke test Task
#Addin "Cake.KeePass"
// If testing a local dll, comment out the #Addin above and uncomment the line below.
// #r "src/Cake.KeePass/bin/Release/Cake.KeePass.dll"
#tool "nuget:?package=xunit.runner.console"
const string Configuration = "Release";
var target = Argument("target", "Build");
var nugetApiKey = Argument<string>("nugetApi", EnvironmentVariable("NugetApiKey"));
var nugetSource = Argument<string>("nugetSource", "https://www.nuget.org/api/v2/package");
var solutionFile = File("./Cake.KeePass.sln");
var artifactsDir = Directory("./artifacts");
var nupkgDestDir = artifactsDir + Directory("nuget-package");
Task("Clean")
.Does(() => {
CleanDirectories(new DirectoryPath[] {
artifactsDir,
nupkgDestDir
});
try {
CleanDirectories("./**/bin/**");
} catch (Exception exception) {
Warning("Failed to clean one or more directories.");
}
});
Task("Build")
.IsDependentOn("Clean")
.Does(() => {
Information("Restoring Nuget Packages");
NuGetRestore(solutionFile);
var settings = new MSBuildSettings();
settings.Configuration = Configuration;
settings.WithTarget("build");
Information("Compiling Solution");
MSBuild(solutionFile, settings);
});
Task("Integration-Test")
.IsDependentOn("Build")
.Does(() => {
Information("Running KeePass integration tests");
XUnit2("./test/integration/**/bin/**/*.Test.Integration.dll");
});
Task("Smoke-Test")
.Does(() => {
Information("Attempting Password retrieval.");
var dbSettings = new KeePassDatabaseSettings {
DatabasePath = "./test/IntegrationTestDatabase.kdbx",
MasterPassword = "Pass@word!"
};
var entryCriteria = new KeePassEntryCriteria {
GroupHierarchy = new []{ "One", "Two", "Three" },
Uuid = "B0160DB1A014994E996D0D18836BDE4D"
};
var entry = KeePassReadEntry(dbSettings, entryCriteria);
Information("Entry Password is: " + entry.Password);
});
Task("Package")
.Does(() => {
var nuGetPackSettings = new NuGetPackSettings {
Version = "1.0.0",
BasePath = "./",
OutputDirectory = nupkgDestDir
};
NuGetPack(File("Cake.KeePass.nuspec"), nuGetPackSettings);
});
Task("Publish")
.IsDependentOn("Package")
.Does(() => {
var packages = GetFiles(nupkgDestDir.Path + "/Cake.KeePass.*.nupkg");
foreach (var package in packages) {
// Push the package.
NuGetPush(package, new NuGetPushSettings {
Source = nugetSource,
ApiKey = nugetApiKey
});
}
});
RunTarget(target);