build-new.ps1 5.3 KB

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