build-new.ps1 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
  2. $configuration = "Release"
  3. $nuspecDir = Join-Path $scriptPath "NuSpecs"
  4. if (!(Test-Path .\nuget.exe)) {
  5. wget "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -outfile .\nuget.exe
  6. }
  7. $msbuild = Get-ItemProperty "hklm:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0"
  8. # TODO: if not found, bail out
  9. $msbuildExe = Join-Path $msbuild.MSBuildToolsPath "msbuild.exe"
  10. # get version
  11. .\nuget.exe install -excludeversion -pre gitversion.commandline -Version 3.5.5-pullrequest0921 -outputdirectory packages
  12. .\packages\gitversion.commandline\tools\gitversion.exe /l console /output buildserver /updateassemblyinfo
  13. $versionObj = .\packages\gitversion.commandline\tools\gitversion.exe | ConvertFrom-Json
  14. $version = $versionObj.MajorMinorPatch
  15. $tag = $versionObj.PreReleaseLabel
  16. $preRelNum = $versionObj.CommitsSinceVersionSourcePadded
  17. if($tag -ne ""){
  18. $version = "$version-$tag-$preRelNum"
  19. }
  20. Write-Host "Version: $version"
  21. Write-Host "Restoring packages" -Foreground Green
  22. dotnet restore $scriptPath | out-null
  23. #need to ensure core is built first due to bad dependency order determination by dotnet build
  24. $coreDir = gci $scriptPath -Directory | where-object {$_.Name -eq "System.Reactive.Core"} | Select -First 1
  25. dotnet build -c "$configuration" $coreDir.FullName
  26. Write-Host "Building projects" -Foreground Green
  27. $projects = gci $scriptPath -Directory `
  28. | Where-Object { ($_.Name -notlike "*DeviceRunner") -and (Test-Path (Join-Path $_.FullName "project.json")) } `
  29. foreach ($project in $projects) {
  30. dotnet build -c "$configuration" $project.FullName
  31. }
  32. Write-Host "Building Packages" -Foreground Green
  33. $nuspecs = ls $nuspecDir\*.nuspec | Select -ExpandProperty FullName
  34. New-Item -ItemType Directory -Force -Path .\artifacts
  35. foreach ($nuspec in $nuspecs)
  36. {
  37. $symbolSwitch = "-symbols"
  38. # nuget will error if we pass -symbols to the meta-package
  39. if($nuSpec -like "*\System.Reactive.nuspec")
  40. {
  41. $symbolSwitch = ""
  42. }
  43. .\nuget pack $nuspec $symbolSwitch -Version $version -Properties "Configuration=$configuration" -MinClientVersion 2.12 -outputdirectory .\artifacts
  44. }
  45. Write-Host "Running tests" -Foreground Green
  46. $testDirectory = Join-Path $scriptPath "Tests.System.Reactive"
  47. dotnet test $testDirectory -c "$configuration"
  48. Write-Host "Reverting AssemblyInfo's" -Foreground Green
  49. gci $scriptPath -re -in AssemblyInfo.cs | %{ git checkout $_ }