build-new.ps1 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.NuGetVersionV2
  15. Write-Host "Version: $version"
  16. # Get Reference Generator
  17. .\nuget.exe install -excludeversion -pre NuSpec.ReferenceGenerator -outputdirectory packages
  18. Write-Host "Restoring packages" -Foreground Green
  19. dotnet restore $scriptPath | out-null
  20. #need to ensure core is built first due to bad dependency order determination by dotnet build
  21. $coreDir = gci . -Directory | where-object {$_.Name -eq "System.Reactive.Core"} | Select -First 1
  22. dotnet build -c "$configuration" $coreDir.FullName
  23. Write-Host "Building projects" -Foreground Green
  24. $projects = gci $scriptPath -Directory `
  25. | Where-Object { ($_.Name -notlike "*DeviceRunner") -and (Test-Path (Join-Path $_.FullName "project.json")) } `
  26. foreach ($project in $projects) {
  27. dotnet build -c "$configuration" $project.FullName
  28. $ns = Join-Path $nuSpecDir "$($project.Name).nuspec"
  29. if(Test-Path $ns)
  30. {
  31. Write-Host "Invoking RefGen on $ns"
  32. $baseDir = Join-Path $project.FullName "bin" | join-path -ChildPath "$configuration"
  33. $projJson = Join-Path $project.FullName "project.json"
  34. Write-Host RefGen.exe generate-cross "-p" `"$projJson`" "-d" `"$baseDir`" "-l" `"$($project.Name).dll`" "-n" `"$ns`"
  35. .\packages\nuspec.referencegenerator\tools\RefGen.exe generate-cross -p "$projJson" -d "$baseDir" -l "$($project.Name).dll" -n "$ns"
  36. }
  37. }
  38. Write-Host "Building Packages" -Foreground Green
  39. $nuspecs = ls $nuspecDir\*.nuspec | Select -ExpandProperty FullName
  40. New-Item -ItemType Directory -Force -Path .\artifacts
  41. foreach ($nuspec in $nuspecs) {
  42. .\nuget pack $nuspec -Version $version -Properties "Configuration=$configuration" -MinClientVersion 2.8.6 -outputdirectory .\artifacts
  43. }
  44. Write-Host "Running tests" -Foreground Green
  45. $testDirectory = Join-Path $scriptPath "Tests.System.Reactive"
  46. dotnet test $testDirectory -c "$configuration"