build-new.ps1 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
  2. $configuration = "Release"
  3. if (!(Test-Path .\nuget.exe)) {
  4. wget "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -outfile .\nuget.exe
  5. }
  6. $msbuild = Get-ItemProperty "hklm:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0"
  7. # TODO: if not found, bail out
  8. $msbuildExe = Join-Path $msbuild.MSBuildToolsPath "msbuild.exe"
  9. # get version
  10. .\nuget.exe install -excludeversion -pre gitversion.commandline -outputdirectory packages
  11. .\packages\gitversion.commandline\tools\gitversion.exe /l console /output buildserver /updateassemblyinfo
  12. $versionObj = .\packages\gitversion.commandline\tools\gitversion.exe | ConvertFrom-Json
  13. $version = $versionObj.NuGetVersionV2
  14. Write-Host "Version: $version"
  15. Write-Host "Restoring packages" -Foreground Green
  16. dotnet restore $scriptPath | out-null
  17. Write-Host "Building projects" -Foreground Green
  18. $projects = gci $scriptPath -Directory `
  19. | Where-Object { Test-Path (Join-Path $_.FullName "project.json") } `
  20. | Select -ExpandProperty FullName
  21. foreach ($project in $projects) {
  22. dotnet build -c "$configuration" $project
  23. }
  24. $nuspecDir = Join-Path $scriptPath "NuSpecs"
  25. Write-Host "Building Packages" -Foreground Green
  26. $nuspecs = ls $nuspecDir\*.nuspec | Select -ExpandProperty FullName
  27. New-Item -ItemType Directory -Force -Path .\artifacts
  28. foreach ($nuspec in $nuspecs) {
  29. .\nuget pack $nuspec -Version $version -Properties "Configuration=$configuration" -MinClientVersion 3.4 -outputdirectory .\artifacts
  30. }
  31. Write-Host "Running tests" -Foreground Green
  32. $testDirectory = Join-Path $scriptPath "Tests.System.Reactive"
  33. dotnet test $testDirectory -c "$configuration"