forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.ps1
388 lines (311 loc) · 13.1 KB
/
default.ps1
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
properties {
$base_dir = resolve-path .
$lib_dir = "$base_dir\SharedLibs"
$build_dir = "$base_dir\build"
$buildartifacts_dir = "$build_dir\"
$sln_file = "$base_dir\zzz_RavenDB_Release.sln"
$version = "1.0.0"
$tools_dir = "$base_dir\Tools"
$release_dir = "$base_dir\Release"
$uploader = "..\Uploader\S3Uploader.exe"
}
include .\psake_ext.ps1
task default -depends OpenSource,Release
task Verify40 {
if( (ls "$env:windir\Microsoft.NET\Framework\v4.0*") -eq $null ) {
throw "Building Raven requires .NET 4.0, which doesn't appear to be installed on this machine"
}
}
task Clean {
remove-item -force -recurse $buildartifacts_dir -ErrorAction SilentlyContinue
remove-item -force -recurse $release_dir -ErrorAction SilentlyContinue
}
task Init -depends Verify40, Clean {
if($env:buildlabel -eq $null) {
$env:buildlabel = "13"
}
$projectFiles = ls -path $base_dir -include *.csproj -recurse |
Where { $_ -notmatch [regex]::Escape($lib_dir) } |
Where { $_ -notmatch [regex]::Escape($tools_dir) }
foreach($projectFile in $projectFiles) {
$projectDir = [System.IO.Path]::GetDirectoryName($projectFile)
$projectName = [System.IO.Path]::GetFileName($projectDir)
$asmInfo = [System.IO.Path]::Combine($projectDir, [System.IO.Path]::Combine("Properties", "AssemblyInfo.cs"))
Generate-Assembly-Info `
-file $asmInfo `
-title "$projectName $version.0" `
-description "A linq enabled document database for .NET" `
-company "Hibernating Rhinos" `
-product "RavenDB $version.0" `
-version "$version.0" `
-fileversion "1.0.0.$env:buildlabel" `
-copyright "Copyright © Hibernating Rhinos and Ayende Rahien 2004 - 2010" `
-clsCompliant "true"
}
new-item $release_dir -itemType directory
new-item $buildartifacts_dir -itemType directory
copy $tools_dir\xUnit\*.* $build_dir
if($global:commercial) {
exec { .\Utilities\Binaries\Raven.ProjectRewriter.exe commercial }
cp "..\RavenDB_Commercial.snk" "Raven.Database\RavenDB.snk"
}
else {
exec { .\Utilities\Binaries\Raven.ProjectRewriter.exe }
cp "Raven.Database\Raven.Database.csproj" "Raven.Database\Raven.Database.g.csproj"
}
}
task Compile -depends Init {
$v4_net_version = (ls "$env:windir\Microsoft.NET\Framework\v4.0*").Name
exec { &"C:\Windows\Microsoft.NET\Framework\$v4_net_version\MSBuild.exe" "$sln_file" /p:OutDir="$buildartifacts_dir\" }
Write-Host "Merging..."
$old = pwd
cd $build_dir
exec { ..\Utilities\Binaries\Raven.Merger.exe }
cd $old
Write-Host "Finished merging"
exec { & "C:\Windows\Microsoft.NET\Framework\$v4_net_version\MSBuild.exe" "$base_dir\Bundles\Raven.Bundles.sln" /p:OutDir="$buildartifacts_dir\" }
exec { & "C:\Windows\Microsoft.NET\Framework\$v4_net_version\MSBuild.exe" "$base_dir\Samples\Raven.Samples.sln" /p:OutDir="$buildartifacts_dir\" }
}
task Test -depends Compile {
$old = pwd
cd $build_dir
exec { &"$build_dir\xunit.console.clr4.exe" "$build_dir\Raven.Munin.Tests.dll" }
exec { &"$build_dir\xunit.console.clr4.exe" "$build_dir\Raven.Tests.dll" }
exec { &"$build_dir\xunit.console.clr4.exe" "$build_dir\Raven.Scenarios.dll" }
exec { &"$build_dir\xunit.console.clr4.exe" "$build_dir\Raven.Client.VisualBasic.Tests.dll" }
exec { &"$build_dir\xunit.console.clr4.exe" "$build_dir\Raven.Bundles.Tests.dll" }
cd $old
}
task ReleaseNoTests -depends OpenSource,DoRelease {
}
task Commercial {
$global:commercial = $true
$global:uploadCategory = "RavenDB-Commercial"
}
task Unstable {
$global:commercial = $false
$global:uploadCategory = "RavenDB-Unstable"
}
task OpenSource {
$global:commercial = $false
$global:uploadCategory = "RavenDB"
}
task Release -depends Test,DoRelease {
}
task CopySamples {
$samples = @("MvcMusicStore", "Raven.Sample.ShardClient", "Raven.Sample.Failover", "Raven.Sample.Replication", "Raven.Sample.EventSourcing", "Raven.Bundles.Sample.EventSourcing.ShoppingCartAggregator", "Raven.Samples.IndexReplication", "Raven.Samples.Includes", "Raven.Sample.SimpleClient", "Raven.Sample.ComplexSharding")
$exclude = @("bin", "obj", "Data", "Plugins")
foreach ($sample in $samples) {
echo $sample
Delete-Sample-Data-For-Release "$base_dir\Samples\$sample"
cp "$base_dir\Samples\$sample" "$build_dir\Output\Samples" -recurse -force
Delete-Sample-Data-For-Release "$build_dir\Output\Samples\$sample"
}
cp "$base_dir\Samples\Raven.Samples.sln" "$build_dir\Output\Samples" -force
exec { .\Utilities\Binaries\Raven.Samples.PrepareForRelease.exe "$build_dir\Output\Samples\Raven.Samples.sln" "$build_dir\Output" }
}
task CreateOutpuDirectories -depends CleanOutputDirectory {
mkdir $build_dir\Output
mkdir $build_dir\Output\lib
mkdir $build_dir\Output\Web
mkdir $build_dir\Output\Web\bin
mkdir $build_dir\Output\Server
mkdir $build_dir\Output\EmbeddedClient
mkdir $build_dir\Output\Client-3.5
mkdir $build_dir\Output\Client
mkdir $build_dir\Output\Bundles
mkdir $build_dir\Output\Samples
}
task CleanOutputDirectory {
remove-item $build_dir\Output -Recurse -Force -ErrorAction SilentlyContinue
}
task CopyEmbeddedClient {
cp $build_dir\Raven.Client.Lightweight.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Client.Lightweight.xml $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Client.Embedded.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Client.Embedded.xml $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Abstractions.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Http.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Database.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Http.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Esent.Interop.dll $build_dir\Output\EmbeddedClient
cp $build_dir\ICSharpCode.NRefactory.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Lucene.Net.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Spatial.Net.dll $build_dir\Output\EmbeddedClient
cp $build_dir\log4net.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Newtonsoft.Json.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Storage.Esent.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Storage.Managed.dll $build_dir\Output\EmbeddedClient
cp $build_dir\Raven.Munin.dll $build_dir\Output\EmbeddedClient
}
task CopySmuggler {
cp $build_dir\RavenSmuggler.exe $build_dir\Output
}
task CopyClient {
cp $build_dir\Newtonsoft.Json.dll $build_dir\Output\Client
cp $build_dir\Raven.Abstractions.dll $build_dir\Output\Client
cp $build_dir\Raven.Client.Lightweight.dll $build_dir\Output\Client
cp $build_dir\Raven.Client.Lightweight.xml $build_dir\Output\Client
}
task CopyClient35 {
cp $build_dir\Newtonsoft.Json.dll $build_dir\Output\Client-3.5
cp $build_dir\Raven.Abstractions-3.5.dll $build_dir\Output\Client-3.5
cp $build_dir\Raven.Client.Lightweight-3.5.dll $build_dir\Output\Client-3.5
}
task CopyWeb {
cp $build_dir\Raven.Abstractions.dll $build_dir\Output\Web\bin
cp $build_dir\Raven.Web.dll $build_dir\Output\Web\bin
cp $build_dir\log4net.dll $build_dir\Output\Web\bin
cp $build_dir\Newtonsoft.Json.dll $build_dir\Output\Web\bin
cp $build_dir\Lucene.Net.dll $build_dir\Output\Web\bin
cp $build_dir\Spatial.Net.dll $build_dir\Output\Web\bin
cp $build_dir\ICSharpCode.NRefactory.dll $build_dir\Output\Web\bin
cp $build_dir\Rhino.Licensing.dll $build_dir\Output\Web\bin
cp $build_dir\Esent.Interop.dll $build_dir\Output\Web\bin
cp $build_dir\Raven.Database.dll $build_dir\Output\Web\bin
cp $build_dir\Raven.Http.dll $build_dir\Output\Web\bin
cp $build_dir\Raven.Storage.Esent.dll $build_dir\Output\Web\bin
cp $build_dir\Raven.Storage.Managed.dll $build_dir\Output\Web\bin
cp $build_dir\Raven.Munin.dll $build_dir\Output\Web\bin
cp $base_dir\DefaultConfigs\web.config $build_dir\Output\Web\web.config
}
task CopyBundles {
cp $build_dir\Raven.Bundles.*.dll $build_dir\Output\Bundles
cp $build_dir\Raven.Client.*.dll $build_dir\Output\Bundles
del $build_dir\Output\Bundles\Raven.Bundles.Tests.dll
}
task CopyServer {
cp $build_dir\Raven.Server.exe $build_dir\Output\Server
cp $build_dir\log4net.dll $build_dir\Output\Server
cp $build_dir\Newtonsoft.Json.dll $build_dir\Output\Server
cp $build_dir\Lucene.Net.dll $build_dir\Output\Server
cp $build_dir\Spatial.Net.dll $build_dir\Output\Server
cp $build_dir\ICSharpCode.NRefactory.dll $build_dir\Output\Server
cp $build_dir\Rhino.Licensing.dll $build_dir\Output\Server
cp $build_dir\Esent.Interop.dll $build_dir\Output\Server
cp $build_dir\Raven.Abstractions.dll $build_dir\Output\Server
cp $build_dir\Raven.Database.dll $build_dir\Output\Server
cp $build_dir\Raven.Http.dll $build_dir\Output\Server
cp $build_dir\Raven.Storage.Esent.dll $build_dir\Output\Server
cp $build_dir\Raven.Storage.Managed.dll $build_dir\Output\Server
cp $build_dir\Raven.Munin.dll $build_dir\Output\Server
cp $base_dir\DefaultConfigs\RavenDb.exe.config $build_dir\Output\Server\Raven.Server.exe.config
}
task CreateNupack {
del $base_dir\*.nupkg
remove-item $build_dir\NuPack -force -recurse -erroraction silentlycontinue
mkdir $build_dir\NuPack
mkdir $build_dir\NuPack\Lib
mkdir $build_dir\NuPack\Lib\3.5
mkdir $build_dir\NuPack\Lib\4.0
mkdir $build_dir\NuPack\Tools
$nupack = [xml](get-content $base_dir\RavenDB.nuspec)
$nupack.package.metadata.version = "$version.$env:buildlabel"
$writerSettings = new-object System.Xml.XmlWriterSettings
$writerSettings.OmitXmlDeclaration = $true
$writerSettings.NewLineOnAttributes = $true
$writerSettings.Indent = $true
$writer = [System.Xml.XmlWriter]::Create("$build_dir\Nupack\RavenDB.nuspec", $writerSettings)
$nupack.WriteTo($writer)
$writer.Flush()
$writer.Close()
cp $build_dir\Newtonsoft.Json.dll $build_dir\NuPack\Lib\3.5
cp $build_dir\Raven.Client.Lightweight-3.5.dll $build_dir\NuPack\Lib\3.5
cp $build_dir\Raven.Client.Lightweight-3.5.xml $build_dir\NuPack\Lib\3.5
cp $build_dir\Raven.Abstractions-3.5.dll $build_dir\NuPack\Lib\3.5
cp $build_dir\Newtonsoft.Json.dll $build_dir\NuPack\Lib\4.0
cp $build_dir\Raven.Client.Lightweight.dll $build_dir\NuPack\Lib\4.0
cp $build_dir\Raven.Abstractions.dll $build_dir\NuPack\Lib\4.0
cp $build_dir\Raven.Client.Lightweight.xml $build_dir\NuPack\Lib\4.0
cp $build_dir\Raven.Server.exe $build_dir\NuPack\Tools
cp $build_dir\log4net.dll $build_dir\NuPack\Tools
cp $build_dir\Newtonsoft.Json.dll $build_dir\NuPack\Tools
cp $build_dir\Lucene.Net.dll $build_dir\NuPack\Tools
cp $build_dir\Spatial.Net.dll $build_dir\NuPack\Tools
cp $build_dir\ICSharpCode.NRefactory.dll $build_dir\NuPack\Tools
cp $build_dir\Rhino.Licensing.dll $build_dir\NuPack\Toolsr
cp $build_dir\Esent.Interop.dll $build_dir\NuPack\Tools
cp $build_dir\Raven.Database.dll $build_dir\NuPack\Tools
cp $build_dir\Raven.Http.dll $build_dir\NuPack\Tools
cp $build_dir\Raven.Storage.Esent.dll $build_dir\NuPack\Tools
cp $build_dir\Raven.Storage.Managed.dll $build_dir\NuPack\Tools
cp $build_dir\Raven.Munin.dll $build_dir\NuPack\Tools
cp $base_dir\DefaultConfigs\RavenDb.exe.config $build_dir\NuPack\Tools\Raven.Server.exe.config
& $tools_dir\NuPack.exe $build_dir\NuPack\RavenDB.nuspec
}
task CreateDocs {
$v4_net_version = (ls "$env:windir\Microsoft.NET\Framework\v4.0*").Name
if($env:buildlabel -eq 13)
{
return
}
# we expliclty allows this to fail
& "C:\Windows\Microsoft.NET\Framework\$v4_net_version\MSBuild.exe" "$base_dir\Raven.Docs.shfbproj" /p:OutDir="$buildartifacts_dir\"
}
task CopyDocFiles -depends CreateDocs {
cp $base_dir\license.txt $build_dir\Output\license.txt
cp $base_dir\readme.txt $build_dir\Output\readme.txt
cp $base_dir\Help\Documentation.chm $build_dir\Output\Documentation.chm -ErrorAction SilentlyContinue
cp $base_dir\acknowledgements.txt $build_dir\Output\acknowledgements.txt
}
task DoRelease -depends Compile, `
CleanOutputDirectory,`
CreateOutpuDirectories, `
CopyEmbeddedClient, `
CopySmuggler, `
CopyClient, `
CopyClient35, `
CopyWeb, `
CopyBundles, `
CopyServer, `
CopyDocFiles, `
CopySamples, `
CreateNupack {
$old = pwd
cd $build_dir\Output
$file = "$release_dir\$global:uploadCategory-Build-$env:buildlabel.zip"
exec {
& $tools_dir\zip.exe -9 -A -r `
$file `
EmbeddedClient\*.* `
Client\*.* `
Samples\*.* `
Samples\*.* `
Client-3.5\*.* `
Web\*.* `
Bundles\*.* `
Web\bin\*.* `
Server\*.* `
*.*
}
cd $old
ExecuteTask("ResetBuildArtifcats")
}
task ResetBuildArtifcats {
git checkout "Raven.Database\RavenDB.snk"
}
task Upload -depends DoRelease {
Write-Host "Starting upload"
if (Test-Path $uploader) {
$log = $env:push_msg
if($log -eq $null -or $log.Length -eq 0) {
$log = git log -n 1 --oneline
}
$file = "$release_dir\$global:uploadCategory-Build-$env:buildlabel.zip"
write-host "Executing: $uploader '$global:uploadCategory' $file '$log'"
&$uploader "$uploadCategory" $file "$log"
if ($lastExitCode -ne 0) {
write-host "Failed to upload to S3: $lastExitCode"
throw "Error: Failed to publish build"
}
}
else {
Write-Host "could not find upload script $uploadScript, skipping upload"
}
}
task UploadCommercial -depends Commercial, DoRelease, Upload {
}
task UploadOpenSource -depends OpenSource, DoRelease, Upload {
}
task UploadUnstable -depends Unstable, DoRelease, Upload {
}