build-new.ps1 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 gitversion.commandline -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. if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
  32. }
  33. Write-Host "Building Packages" -Foreground Green
  34. $nuspecs = ls $nuspecDir\*.nuspec | Select -ExpandProperty FullName
  35. New-Item -ItemType Directory -Force -Path .\artifacts
  36. foreach ($nuspec in $nuspecs)
  37. {
  38. $symbolSwitch = "-symbols"
  39. # nuget will error if we pass -symbols to the meta-package
  40. if($nuSpec -like "*\System.Reactive.nuspec")
  41. {
  42. $symbolSwitch = ""
  43. }
  44. .\nuget pack $nuspec $symbolSwitch -Version $version -Properties "Configuration=$configuration" -MinClientVersion 2.12 -outputdirectory .\artifacts
  45. if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
  46. }
  47. Write-Host "Running tests" -Foreground Green
  48. $testDirectory = Join-Path $scriptPath "Tests.System.Reactive"
  49. dotnet test $testDirectory -c "$configuration"
  50. if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
  51. Write-Host "Reverting AssemblyInfo's" -Foreground Green
  52. gci $scriptPath -re -in AssemblyInfo.cs | %{ git checkout $_ }