build-new.ps1 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
  2. $configuration = "Release"
  3. $isAppVeyor = Test-Path -Path env:\APPVEYOR
  4. $outputLocation = Join-Path $scriptPath "testResults"
  5. $openCoverPath = ".\packages\OpenCover\tools\OpenCover.Console.exe"
  6. $rootPath = (Resolve-Path .).Path
  7. $artifacts = Join-Path $rootPath "artifacts"
  8. $signClientSettings = Join-Path (Join-Path (Get-Item $scriptPath).Parent.Parent.FullName "scripts") "SignClientSettings.json"
  9. $hasSignClientSecret = !([string]::IsNullOrEmpty($env:SignClientSecret))
  10. $signClientAppPath = Join-Path (Join-Path (Join-Path .\Packages "SignClient") "Tools") "SignClient.dll"
  11. #remove any old coverage file
  12. md -Force $outputLocation | Out-Null
  13. $outputPath = (Resolve-Path $outputLocation).Path
  14. $outputFile = Join-Path $outputPath -childpath 'coverage-rx.xml'
  15. Remove-Item $outputPath -Force -Recurse
  16. md -Force $outputLocation | Out-Null
  17. if (!(Test-Path .\nuget.exe)) {
  18. wget "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -outfile .\nuget.exe
  19. }
  20. # get tools
  21. .\nuget.exe install -excludeversion SignClient -Version 0.5.0-beta4 -pre -outputdirectory packages
  22. .\nuget.exe install -excludeversion OpenCover -outputdirectory packages
  23. .\nuget.exe install -excludeversion ReportGenerator -outputdirectory packages
  24. .\nuget.exe install -excludeversion coveralls.io -outputdirectory packages
  25. New-Item -ItemType Directory -Force -Path $artifacts
  26. Write-Host "Restoring packages for $scriptPath\System.Reactive.sln" -Foreground Green
  27. msbuild "$scriptPath\System.Reactive.sln" /t:restore /p:Configuration=$configuration
  28. Write-Host "Building $scriptPath\System.Reactive\System.Reactive.csproj" -Foreground Green
  29. msbuild "$scriptPath\System.Reactive\System.Reactive.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts
  30. if($hasSignClientSecret) {
  31. Write-Host "Signing Packages" -Foreground Green
  32. $nupgks = ls $artifacts\*React*.nupkg | Select -ExpandProperty FullName
  33. foreach ($nupkg in $nupgks) {
  34. Write-Host "Submitting $nupkg for signing"
  35. dotnet $signClientAppPath 'zip' -c $signClientSettings -i $nupkg -s $env:SignClientSecret -n 'Rx.NET' -d 'Reactive Extensions for .NET' -u 'http://reactivex.io/'
  36. if ($LastExitCode -ne 0) {
  37. Write-Host "Error signing $nupkg" -Foreground Red
  38. if($isAppVeyor) {
  39. $host.SetShouldExit($LastExitCode)
  40. }
  41. }
  42. Write-Host "Finished signing $nupkg"
  43. }
  44. } else {
  45. Write-Host "Client Secret not found, not signing packages"
  46. }
  47. exit # TODO
  48. Write-Host "Running tests" -Foreground Green
  49. $testDirectory = Join-Path $scriptPath "Tests.System.Reactive"
  50. # Execute OpenCover with a target of "dotnet test"
  51. & $openCoverPath -register:user -oldStyle -mergeoutput -target:dotnet.exe -targetdir:"$testDirectory" -targetargs:"test $testDirectory -c $configuration -notrait SkipCI=true" -output:"$outputFile" -skipautoprops -returntargetcode -excludebyattribute:"System.Diagnostics.DebuggerNonUserCodeAttribute;System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" -nodefaultfilters -hideskipped:All -filter:"+[*]* -[*.Tests]* -[Tests.*]* -[xunit.*]* -[*]Xunit.*"
  52. if ($LastExitCode -ne 0) {
  53. Write-Host "Error with tests" -Foreground Red
  54. if($isAppVeyor) {
  55. $host.SetShouldExit($LastExitCode)
  56. }
  57. }
  58. # Either display or publish the results
  59. if ($env:CI -eq 'True')
  60. {
  61. .\packages\coveralls.io\tools\coveralls.net.exe --opencover "$outputFile" --full-sources
  62. }
  63. else
  64. {
  65. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  66. &$outPutPath/index.htm
  67. }