Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: build-473
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 539 lines (407 sloc) 17.311 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 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 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
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"
  
  $web_dlls = @( "Raven.Abstractions.???","Raven.Json.???", "Raven.Web.???", "nlog.???", "Newtonsoft.Json.???", "Lucene.Net.???", "Spatial.Net.???", "SpellChecker.Net.???", "ICSharpCode.NRefactory.???", `
    "Rhino.Licensing.???", "Esent.Interop.???", "Raven.Database.???", "Raven.Http.???", "Raven.Storage.Esent.???", "Raven.Storage.Managed.???", "Raven.Munin.???" );
    
  $web_files = @("Raven.Studio.xap", "..\DefaultConfigs\web.config" );
    
  $server_files = @( "Raven.Server.exe", "Raven.Json.???", "Raven.Studio.xap", "nlog.???", "Newtonsoft.Json.???", "Lucene.Net.???", `
                     "Spatial.Net.???", "SpellChecker.Net.???", "ICSharpCode.NRefactory.???", "Rhino.Licensing.???", "BouncyCastle.Crypto.???", `
                    "Esent.Interop.???", "Raven.Abstractions.???", "Raven.Database.???", "Raven.Http.???", "Raven.Storage.Esent.???", `
                    "Raven.Storage.Managed.???", "Raven.Munin.???" );
    
  $client_dlls_3_5 = @( "nlog.???","Newtonsoft.Json.Net35.???", "Raven.Abstractions-3.5.???", "Raven.Json-3.5.???", "Raven.Client.Lightweight-3.5.???");
     
  $client_dlls = @( "nlog.???","Raven.Client.MvcIntegration.???", "Newtonsoft.Json.???","Raven.Json.???", "Raven.Abstractions.???", "Raven.Client.Lightweight.???", "Raven.Client.Debug.???", `
"AsyncCtpLibrary.???" );
  
  $silverlight_dlls = @( "Raven.Client.Silverlight.???", "AsyncCtpLibrary_Silverlight.???", "MissingBitFromSilverlight.???", "Newtonsoft.Json.Silverlight.???");
  
  $silverlight_dlls_libs = @( "NLog.???");
 
  $all_client_dlls = @( "Raven.Client.Lightweight.???", "Raven.Client.Embedded.???", "Raven.Abstractions.???", "Raven.Http.???", "Raven.Database.???", "Raven.Json.???", `
      "Esent.Interop.???", "ICSharpCode.NRefactory.???", "Lucene.Net.???", "Spatial.Net.???", "SpellChecker.Net.???", "nlog.???", "Newtonsoft.Json.???", `
      "Raven.Storage.Esent.???", "Raven.Storage.Managed.???", "Raven.Munin.???", "AsyncCtpLibrary.???", "Raven.Studio.xap" );
      
  $test_prjs = @("Raven.Tests.dll", "Raven.Client.VisualBasic.Tests.dll", "Raven.Bundles.Tests.dll" );
}
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:BUILD_NUMBER -ne $null) {
    $env:buildlabel = $env:BUILD_NUMBER
}

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) }

$notclsCompliant = @("Raven.Silverlight.Client", "Raven.Studio", "Raven.Tests.Silverlight")

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"))

$clsComliant = "true"

if([System.Array]::IndexOf($notclsCompliant, $projectName) -ne -1) {
      $clsComliant = "false"
}

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 $clsComliant
}

new-item $release_dir -itemType directory -ErrorAction SilentlyContinue
new-item $build_dir -itemType directory -ErrorAction SilentlyContinue

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 BeforeCompile {
if (Test-Path "$base_dir\..\BuildsInfo\RavenDB\Settings.dat") {
cp "$base_dir\..\BuildsInfo\RavenDB\Settings.dat" "$base_dir\Raven.Studio\Settings.dat" -force
}
else {
new-item "$base_dir\Raven.Studio\Settings.dat" -type file -force
}
}

task AfterCompile {
new-item "$base_dir\Raven.Studio\Settings.dat" -type file -force
}


task Compile -depends Init {

$v4_net_version = (ls "$env:windir\Microsoft.NET\Framework\v4.0*").Name
    
    try {
ExecuteTask("BeforeCompile")
exec { &"C:\Windows\Microsoft.NET\Framework\$v4_net_version\MSBuild.exe" "$sln_file" /p:OutDir="$buildartifacts_dir\" }
} catch {
Throw
} finally {
ExecuteTask("AfterCompile")
}
      
  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
  Write-Host $test_prjs
  foreach($test_prj in $test_prjs) {
    Write-Host "Testing $build_dir\$test_prj"
    exec { &"$build_dir\xunit.console.clr4.exe" "$build_dir\$test_prj" }
  }
  cd $old
}

task TestSilverlight {

try{
    start "$build_dir\Raven.Server.exe" "/ram"
    exec {
      & ".\Tools\StatLight\StatLight.exe" "-x=.\build\Raven.Tests.Silverlight.xap" "--OverrideTestProvider=MSTestWithCustomProvider" "--ReportOutputFile=.\Raven.Tests.Silverlight.Results.xml"
    }
}
finally{
    ps "Raven.Server" | kill
}
}

task TestStackoverflowSampleBuilds {

$v4_net_version = (ls "$env:windir\Microsoft.NET\Framework\v4.0*").Name

    exec { & "C:\Windows\Microsoft.NET\Framework\$v4_net_version\MSBuild.exe" "$base_dir\ETL\Raven.Etl.sln" /p:RavenIncludesPath="$buildartifacts_dir\" /p:OutDir="$buildartifacts_dir\Raven.Etl\" }
}

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,TestSilverlight,TestStackoverflowSampleBuilds,DoRelease {
}

task CopySamples {
$samples = @("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", "Raven.Sample.MultiTenancy", "Raven.Sample.Suggestions", `
               "Raven.Sample.LiveProjections", "Raven.Sample.FullTextSearch")
$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\Web
mkdir $build_dir\Output\Web\bin
mkdir $build_dir\Output\Server
mkdir $build_dir\Output\EmbeddedClient
mkdir $build_dir\Output\Silverlight
mkdir $build_dir\Output\Client-3.5
mkdir $build_dir\Output\Client
mkdir $build_dir\Output\Bundles
mkdir $build_dir\Output\Samples
mkdir $build_dir\Output\Smuggler
}

task CleanOutputDirectory {
remove-item $build_dir\Output -Recurse -Force -ErrorAction SilentlyContinue
}

task CopyEmbeddedClient {

  foreach($client_dll in $all_client_dlls) {
    cp "$build_dir\$client_dll" $build_dir\Output\EmbeddedClient
  }
}

task CopySilverlight{

  foreach($silverlight_dll in $silverlight_dlls) {
    cp "$build_dir\$silverlight_dll" $build_dir\Output\Silverlight
    
  }
  
  foreach($silverlight_dll in $silverlight_dlls_libs) {
     cp "$lib_dir\Silverlight\$silverlight_dll" $build_dir\Output\Silverlight
  }
  
}

task CopySmuggler {
cp $build_dir\Raven.Json.??? $build_dir\Output\Smuggler
cp $build_dir\NewtonSoft.Json.??? $build_dir\Output\Smuggler
cp $build_dir\Raven.Smuggler.??? $build_dir\Output\Smuggler
}

task CopyClient {
  foreach($client_dll in $client_dlls) {
    cp "$build_dir\$client_dll" $build_dir\Output\Client
  }
}

task CopyClient35 {
  foreach($client_dll in $client_dlls_3_5) {
    cp "$build_dir\$client_dll" $build_dir\Output\Client-3.5
  }
}

task CopyWeb {
  foreach($web_dll in $web_dlls) {
    cp "$build_dir\$web_dll" $build_dir\Output\Web\bin
  }
  foreach($web_file in $web_files) {
    cp "$build_dir\$web_file" $build_dir\Output\Web
  }
}

task CopyBundles {
cp $build_dir\Raven.Bundles.*.??? $build_dir\Output\Bundles
cp $build_dir\Raven.Client.*.??? $build_dir\Output\Bundles
del $build_dir\Output\Bundles\Raven.Bundles.Tests.???
}

task CopyServer {
   foreach($server_file in $server_files) {
    cp "$build_dir\$server_file" $build_dir\Output\Server
  }

cp $base_dir\DefaultConfigs\RavenDb.exe.config $build_dir\Output\Server\Raven.Server.exe.config
}


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 CopyRootFiles -depends CreateDocs {
cp $base_dir\license.txt $build_dir\Output\license.txt
cp $base_dir\Scripts\Start.cmd $build_dir\Output\Start.cmd
cp $base_dir\Scripts\Raven-StartBackup.ps1 $build_dir\Output\Raven-StartBackup.ps1
cp $base_dir\Scripts\Raven-UpdateBundles.ps1 $build_dir\Output\Raven-UpdateBundles.ps1
cp $base_dir\Scripts\Raven-GetBundles.ps1 $build_dir\Output\Raven-GetBundles.ps1
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\acknowledgments.txt $build_dir\Output\acknowledgments.txt
}

task ZipOutput {

if($env:buildlabel -eq 13)
{
      return
}

$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\*.* `
Smuggler\*.* `
Client-3.5\*.* `
Web\*.* `
Bundles\*.* `
Web\bin\*.* `
Server\*.* `
*.*
}

    cd $old

}

task ResetBuildArtifcats {
    git checkout "Raven.Database\RavenDB.snk"
}


task DoRelease -depends Compile, `
CleanOutputDirectory,`
CreateOutpuDirectories, `
CopyEmbeddedClient, `
CopySmuggler, `
CopyClient, `
CopySilverlight, `
CopyClient35, `
CopyWeb, `
CopyBundles, `
CopyServer, `
CopyRootFiles, `
CopySamples, `
ZipOutput, `
CreateNugetPackage, `
ResetBuildArtifcats {
Write-Host "Done building RavenDB"
}


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 {

}

task CreateNugetPackage {
  $accessPath = "$base_dir\..\Nuget-Access-Key.txt"
  
  if( $global:uploadCategory -ne "RavenDB") # we only publish the stable version out
  {
    Write-Host "Not a stable build, skipping nuget package creation"
    return
  }
  
  if ( (Test-Path $accessPath) -eq $false )
  {
    return;
  }
  
  $accessKey = Get-Content $accessPath
  $accessKey = $accessKey.Trim()
  
  del $base_dir\*.nupkg
remove-item $build_dir\NuPack -force -recurse -erroraction silentlycontinue
mkdir $build_dir\NuPack
mkdir $build_dir\NuPack\content
mkdir $build_dir\NuPack\lib
mkdir $build_dir\NuPack\lib\net35
mkdir $build_dir\NuPack\lib\net40
mkdir $build_dir\NuPack\lib\sl40
mkdir $build_dir\NuPack\tools
mkdir $build_dir\NuPack\server

# package for RavenDB embedded is separate and requires .NET 4.0
remove-item $build_dir\NuPack-Embedded -force -recurse -erroraction silentlycontinue
mkdir $build_dir\NuPack-Embedded
mkdir $build_dir\NuPack-Embedded\content
mkdir $build_dir\NuPack-Embedded\lib\
mkdir $build_dir\NuPack-Embedded\lib\net40
mkdir $build_dir\NuPack-Embedded\tools

foreach($client_dll in $client_dlls_3_5) {
    cp "$build_dir\$client_dll" $build_dir\NuPack\lib\net35
  }

foreach($client_dll in $client_dlls) {
    cp "$build_dir\$client_dll" $build_dir\NuPack\lib\net40
  }

foreach($sl_dll in $silverlight_dlls) {
    cp "$build_dir\$sl_dll" $build_dir\NuPack\lib\sl40
  }
  
  foreach($silverlight_dll in $silverlight_dlls_libs) {
     cp "$lib_dir\Silverlight\$silverlight_dll" $build_dir\NuPack\lib\sl40
  }
  
  foreach($client_dll in $all_client_dlls) {
    cp "$build_dir\$client_dll" $build_dir\NuPack-Embedded\lib\net40
  }

  # Remove files that are obtained as dependencies
  del $build_dir\NuPack\lib\net35\Newtonsoft.Json.*
  del $build_dir\NuPack\lib\net40\Newtonsoft.Json.*
  del $build_dir\NuPack\lib\sl40\Newtonsoft.Json.*
  del $build_dir\NuPack\lib\net35\nlog.*
  del $build_dir\NuPack\lib\net40\nlog.*
  del $build_dir\NuPack\lib\sl40\nlog.*
  del $build_dir\NuPack-Embedded\lib\net40\Newtonsoft.Json.*
  del $build_dir\NuPack-Embedded\lib\net40\nlog.*

  # The Server folder is used as a tool, and therefore needs the dependency DLLs in it (can't depend on Nuget for that)
  foreach($server_file in $server_files) {
    cp "$build_dir\$server_file" $build_dir\NuPack\server
  }

  cp $base_dir\DefaultConfigs\RavenDb.exe.config $build_dir\NuPack\server\Raven.Server.exe.config
  
  cp $base_dir\DefaultConfigs\Nupack.Web.config $build_dir\NuPack\content\Web.config.transform
  cp $base_dir\DefaultConfigs\Nupack.Web.config $build_dir\NuPack-Embedded\content\Web.config.transform
  
  cp $build_dir\Raven.Smuggler.??? $build_dir\NuPack\Tools
  cp $build_dir\Raven.Smuggler.??? $build_dir\NuPack-Embedded\Tools
  

########### First pass - RavenDB.nupkg

  $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()
  
  & "$tools_dir\nuget.exe" pack $build_dir\NuPack\RavenDB.nuspec


########### Second pass - RavenDB-Embedded.nupkg

  $nupack = [xml](get-content $base_dir\RavenDB-Embedded.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-Embedded\RavenDB-Embedded.nuspec", $writerSettings)

  $nupack.WriteTo($writer)
  $writer.Flush()
  $writer.Close()
  
  & "$tools_dir\nuget.exe" pack $build_dir\NuPack-Embedded\RavenDB-Embedded.nuspec
  
  # Push to nuget repository
  & "$tools_dir\nuget.exe" push -source http://packages.nuget.org/v1/ "RavenDB.$version.$env:buildlabel.nupkg" $accessKey
  & "$tools_dir\nuget.exe" push -source http://packages.nuget.org/v1/ "RavenDB-Embedded.$version.$env:buildlabel.nupkg" $accessKey
  
  
  # This is prune to failure since the previous package may not exists
  
  #$prevVersion = ($env:buildlabel - 1)
  # & "$tools_dir\nuget.exe" delete RavenDB "$version.$prevVersion" $accessKey -source http://packages.nuget.org/v1/ -NoPrompt
}
Something went wrong with that request. Please try again.