build-new.ps1 1.6 KB

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