build-new.ps1 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 -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. # Get Reference Generator
  22. .\nuget.exe install -excludeversion -pre NuSpec.ReferenceGenerator -outputdirectory packages
  23. Write-Host "Restoring packages" -Foreground Green
  24. dotnet restore $scriptPath | out-null
  25. #need to ensure core is built first due to bad dependency order determination by dotnet build
  26. $coreDir = gci $scriptPath -Directory | where-object {$_.Name -eq "System.Reactive.Core"} | Select -First 1
  27. dotnet build -c "$configuration" $coreDir.FullName
  28. Write-Host "Building projects" -Foreground Green
  29. $projects = gci $scriptPath -Directory `
  30. | Where-Object { ($_.Name -notlike "*DeviceRunner") -and (Test-Path (Join-Path $_.FullName "project.json")) } `
  31. foreach ($project in $projects) {
  32. dotnet build -c "$configuration" $project.FullName
  33. $ns = Join-Path $nuSpecDir "$($project.Name).nuspec"
  34. if(Test-Path $ns)
  35. {
  36. Write-Host "Invoking RefGen on $ns"
  37. $baseDir = Join-Path $project.FullName "bin" | join-path -ChildPath "$configuration"
  38. $projJson = Join-Path $project.FullName "project.json"
  39. Write-Host RefGen.exe generate-cross "-p" `"$projJson`" "-d" `"$baseDir`" "-l" `"$($project.Name).dll`" "-n" `"$ns`"
  40. .\packages\nuspec.referencegenerator\tools\RefGen.exe generate-cross -p "$projJson" -d "$baseDir" -l "$($project.Name).dll" -n "$ns"
  41. }
  42. }
  43. Write-Host "Building Packages" -Foreground Green
  44. $nuspecs = ls $nuspecDir\*.nuspec | Select -ExpandProperty FullName
  45. New-Item -ItemType Directory -Force -Path .\artifacts
  46. foreach ($nuspec in $nuspecs)
  47. {
  48. $symbolSwitch = "-symbols"
  49. # nuget will error if we pass -symbols to the meta-package
  50. if($nuSpec -like "*\System.Reactive.nuspec")
  51. {
  52. $symbolSwitch = ""
  53. }
  54. .\nuget pack $nuspec $symbolSwitch -Version $version -Properties "Configuration=$configuration" -MinClientVersion 2.8.6 -outputdirectory .\artifacts
  55. }
  56. Write-Host "Running tests" -Foreground Green
  57. $testDirectory = Join-Path $scriptPath "Tests.System.Reactive"
  58. dotnet test $testDirectory -c "$configuration"
  59. Write-Host "Reverting AssemblyInfo's" -Foreground Green
  60. gci $scriptPath -re -in AssemblyInfo.cs | %{ git checkout $_ }