forked from OrleansContrib/Orleankka
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNake.csx
More file actions
208 lines (175 loc) · 5.52 KB
/
Nake.csx
File metadata and controls
208 lines (175 loc) · 5.52 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#r "System.Xml"
#r "System.Xml.Linq"
#r "System.IO.Compression"
#r "System.IO.Compression.FileSystem"
using Nake.FS;
using Nake.Run;
using Nake.Log;
using Nake.Env;
using Nake.App;
using System.Linq;
using System.Net;
using System.Xml.Linq;
using System.Diagnostics;
using System.IO.Compression;
const string CoreProject = "Orleankka";
const string AzureProject = "Orleankka.Azure";
const string TestKitProject = "Orleankka.TestKit";
const string FSharpProject = "Orleankka.FSharp";
const string Beta = "";
const string RootPath = "$NakeScriptDirectory$";
const string OutputPath = RootPath + @"\Output";
var PackagePath = @"{OutputPath}\Package";
var ReleasePath = @"{PackagePath}\Release";
var AppVeyor = Var["APPVEYOR"] == "True";
var GES = "EventStore-OSS-Win-v3.0.3";
var Nuget = @"{RootPath}\Packages\NuGet.CommandLine\tools\Nuget.exe";
/// Installs dependencies and builds sources in Debug mode
[Task] void Default()
{
Install();
Build();
}
/// Wipeout all build output and temporary build files
[Step] void Clean(string path = OutputPath)
{
Delete(@"{path}\*.*|-:*.vshost.exe");
RemoveDir(@"**\bin|**\obj|{path}\*|-:*.vshost.exe");
}
/// Builds sources using specified configuration and output path
[Step] void Build(string config = "Debug", string outDir = OutputPath, bool verbose = false)
{
Clean(outDir);
Exec(@"$ProgramFiles(x86)$\MSBuild\14.0\Bin\MSBuild.exe",
"{CoreProject}.sln /p:Configuration={config};OutDir=\"{outDir}\";ReferencePath=\"{outDir}\"" +
(verbose ? "/v:d" : ""));
}
/// Runs unit tests
[Step] void Test(string outDir = OutputPath, bool slow = false)
{
Build("Debug", outDir);
var tests = new FileSet{@"{outDir}\*.Tests.dll"}.ToString(" ");
var results = @"{outDir}\nunit-test-results.xml";
try
{
Cmd(@"Packages\NUnit.Runners\tools\nunit-console.exe " +
@"/xml:{results} /framework:net-4.0 /noshadow /nologo {tests} " +
(AppVeyor||slow ? "/include:Always,Slow" : ""));
}
finally
{
if (AppVeyor)
new WebClient().UploadFile("https://ci.appveyor.com/api/testresults/nunit/$APPVEYOR_JOB_ID$", results);
}
}
/// Builds official NuGet packages
[Step] void Package()
{
Test(@"{PackagePath}\Debug");
Build("Package", ReleasePath);
Pack(CoreProject);
Pack(TestKitProject, "core_version={Version(CoreProject)}");
Pack(AzureProject, "core_version={Version(CoreProject)}");
Pack(FSharpProject, "core_version={Version(CoreProject)}");
}
void Pack(string project, string properties = null)
{
Cmd(@"{Nuget} pack Build\{project}.nuspec -Version {Version(project)} " +
"-OutputDirectory {PackagePath} -BasePath {RootPath} -NoPackageAnalysis " +
(properties != null ? "-Properties {properties}" : ""));
}
/// Publishes package to NuGet gallery
[Step] void Publish(string project)
{
switch (project)
{
case "core":
Push(CoreProject);
break;
case "azure":
Push(AzureProject);
break;
case "testkit":
Push(TestKitProject);
break;
case "fsharp":
Push(FSharpProject);
break;
case "all":
Push(CoreProject);
Push(AzureProject);
Push(TestKitProject);
Push(FSharpProject);
break;
default:
throw new ArgumentException("Available values are: core, azure, testkit, fsharp or all");
}
}
void Push(string project)
{
Cmd(@"{Nuget} push {PackagePath}\{project}.{Version(project)}.nupkg $NuGetApiKey$ -Source https://nuget.org/");
}
string Version(string project)
{
var result = FileVersionInfo
.GetVersionInfo(@"{ReleasePath}\{project}.dll")
.FileVersion;
if (Beta != "")
result = result.Substring(0, result.LastIndexOf(".")) + "-{Beta}";
return result;
}
/// Installs binary dependencies
[Task] void Install()
{
var packagesDir = @"{RootPath}\Packages";
if (!Directory.Exists(@"{packagesDir}\{GES}"))
{
Info("EventStore binaries were not found. Downloading ...");
new WebClient().DownloadFile(
"http://download.geteventstore.com/binaries/{GES}.zip",
@"{packagesDir}\{GES}.zip"
);
Info("Success! Extracting ...");
ZipFile.ExtractToDirectory(@"{packagesDir}\{GES}.zip", @"{packagesDir}\{GES}");
File.Delete(@"{packagesDir}\{GES}.zip");
Info("Done!");
}
}
/// Runs 3rd party software, on which samples are dependent upon
[Task] void Run(string what = "all")
{
switch (what)
{
case "all":
RunAzure();
RunGES();
break;
case "ges":
RunGES();
break;
case "azure":
RunAzure();
break;
default:
throw new ArgumentException("Available values are: all, ges, azure ...");
}
}
void RunGES()
{
if (IsRunning("EventStore.ClusterNode"))
return;
Info("Starting local GES node ...");
Exec(@"{RootPath}/Packages/{GES}/EventStore.ClusterNode.exe", "");
}
void RunAzure()
{
if (IsRunning("AzureStorageEmulator"))
return;
Info("Starting storage emulator ...");
Exec(@"C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe", "start");
}
bool IsRunning(string processName)
{
var processes = Process.GetProcesses().Select(x => x.ProcessName).ToList();
return (processes.Any(p => p == processName));
}