-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.cake
More file actions
138 lines (120 loc) · 4.38 KB
/
build.cake
File metadata and controls
138 lines (120 loc) · 4.38 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#tool "nuget:?package=xunit.runner.console"
#tool "nuget:?package=GitVersion.CommandLine"
#tool "nuget:?package=ILRepack"
#addin nuget:?package=Cake.Incubator
using Cake.Common.Tools.GitVersion;
using IoPath = System.IO.Path;
using Cake.Incubator;
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
string buildDir = Directory("./src/eCrypt/bin") + Directory(configuration);
string keyGeneratorBuildDir = Directory("./src/eCrypt.KeyGenerator/bin") + Directory(configuration);
string outputDir = Directory("./build_output/artifacts");
string solutionPath = File("./src/eCrypt.sln");
string keyGeneratorExeName = "eVision.KeyGenerator.exe";
string toolExeName = "eVision.eCrypt.exe";
string keyGenArtifactsPath = Directory(outputDir) + File(keyGeneratorExeName);
string toolAtrifactsPath = Directory(outputDir) + File(toolExeName);
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
CleanDirectory(keyGeneratorBuildDir);
CleanDirectory(outputDir);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(solutionPath);
});
Task("Update-Assembly-Info")
.Does(() =>
{
if (!BuildSystem.IsLocalBuild)
{
GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.BuildServer
});
}
GitVersion version = GitVersion(new GitVersionSettings { UpdateAssemblyInfo = false, OutputType = GitVersionOutput.Json });
Information("Version: " + version.NuGetVersion);
});
Task("Build")
.IsDependentOn("Update-Assembly-Info")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
MSBuild(solutionPath, settings => settings.SetConfiguration(configuration));
});
Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
var testAssemblies = GetFiles("./**/bin/Release/*.Tests.dll");
XUnit2(testAssemblies);
});
Task("Merge-Libraries")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
{
string primaryAssembly = Directory(keyGeneratorBuildDir) + File(keyGeneratorExeName);
var assemblyPaths = new string[] {
"BouncyCastle.*",
"CommandLine",
"Xceed.Wpf.Toolkit",
"GalaSoft.*",
"MahApps.Metro",
"Microsoft.Practices.ServiceLocation",
"Microsoft.WindowsAPICodePack",
"Newtonsoft.Json",
"NLog",
"Prism",
"Ookii.Dialogs.Wpf",
//"Xceed.*", These dlls are embedded as resources
"System.*"
}.Select(path => string.Format("{0}/{1}.dll", keyGeneratorBuildDir, path))
.ToArray();
CopyFile(Directory(buildDir) + File(toolExeName), toolAtrifactsPath);
ILRepack(keyGenArtifactsPath, primaryAssembly, GetFiles(assemblyPaths), new ILRepackSettings(){
Internalize = true,
Wildcards = true,
AllowDuplicateResources = true,
TargetPlatform = TargetPlatformVersion.v4,
TargetKind = TargetKind.WinExe
});
});
Task("Create-Nuget-Packages")
.IsDependentOn("Merge-Libraries")
.Does(() =>
{
string nugetTarget = "lib/net45";
NuGetPack(GetFiles("./**/eVision.eCrypt.nuspec"), new NuGetPackSettings {
Version = GitVersion(new GitVersionSettings()).AssemblySemVer,
NoPackageAnalysis = true,
BasePath = ".",
OutputDirectory = outputDir,
Files = new [] {
new NuSpecContent {Source = keyGenArtifactsPath, Target = nugetTarget },
new NuSpecContent {Source = toolAtrifactsPath, Target = nugetTarget }
}
});
});
Task("Push-Nuget-Packages")
.IsDependentOn("Create-Nuget-Packages")
.Does(() =>
{
string semVersion = GitVersion(new GitVersionSettings()).SemVer;
var pushSettings = new NuGetPushSettings {
Source = "https://evision.myget.org/F/main/api/v3/index.json",
ApiKey = EnvironmentVariable("NugetApiKey")
};
string package = Directory(outputDir) + File("eVision.eCrypt." + semVersion + ".nupkg");
Information("Publishing nuget package " + package);
NuGetPush(package, pushSettings);
});
Task("Default").IsDependentOn("Run-Unit-Tests");
Task("Package").IsDependentOn("Create-Nuget-Packages");
Task("Publish").IsDependentOn("Push-Nuget-Packages");
RunTarget(target);