build-new.ps1 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. Write-Host "Building projects" -Foreground Green
  21. $projects = gci $scriptPath -Directory `
  22. | Where-Object { Test-Path (Join-Path $_.FullName "project.json") } `
  23. foreach ($project in $projects) {
  24. dotnet build -c "$configuration" $project.FullName
  25. $ns = Join-Path $nuSpecDir "$($project.Name).nuspec"
  26. if(Test-Path $ns)
  27. {
  28. Write-Host "Invoking RefGen on $ns"
  29. $baseDir = Join-Path $project.FullName "bin" | join-path -ChildPath "$configuration"
  30. $projJson = Join-Path $project.FullName "project.json"
  31. Write-Host RefGen.exe generate-cross "-p" `"$projJson`" "-d" `"$baseDir`" "-l" `"$($project.Name).dll`" "-n" `"$ns`"
  32. .\packages\nuspec.referencegenerator\tools\RefGen.exe generate-cross -p "$projJson" -d "$baseDir" -l "$($project.Name).dll" -n "$ns"
  33. }
  34. }
  35. Write-Host "Building Packages" -Foreground Green
  36. $nuspecs = ls $nuspecDir\*.nuspec | Select -ExpandProperty FullName
  37. New-Item -ItemType Directory -Force -Path .\artifacts
  38. foreach ($nuspec in $nuspecs) {
  39. .\nuget pack $nuspec -Version $version -Properties "Configuration=$configuration" -MinClientVersion 2.8.6 -outputdirectory .\artifacts
  40. }
  41. Write-Host "Running tests" -Foreground Green
  42. $testDirectory = Join-Path $scriptPath "Tests.System.Reactive"
  43. dotnet test $testDirectory -c "$configuration"