1
0

build-new.ps1 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
  2. $configuration = "Release"
  3. $isAppVeyor = ((Test-Path -Path env:\APPVEYOR) -Or (Test-Path -Path env:\TF_BUILD))
  4. $outputLocation = Join-Path $scriptPath "testResults"
  5. $openCoverPath = ".\packages\OpenCover\tools\OpenCover.Console.exe"
  6. $xUnitConsolePath = ".\packages\xunit.runner.console\tools\net452\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 = ".\packages\SignClient\tools\netcoreapp2.0\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.9.1 -outputdirectory packages
  23. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -version 2017.3.5 -outputdirectory packages
  24. .\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.1.23 -outputdirectory packages
  25. .\nuget.exe install -excludeversion xunit.runner.console -outputdirectory packages
  26. #.\nuget.exe install -excludeversion OpenCover -Version 4.6.519 -outputdirectory packages
  27. .\nuget.exe install -excludeversion ReportGenerator -outputdirectory packages
  28. #.\nuget.exe install -excludeversion coveralls.io -outputdirectory packages
  29. .\nuget.exe install -excludeversion coveralls.io.dotcover -outputdirectory packages
  30. #update version
  31. $versionObj = .\packages\Nerdbank.GitVersioning\tools\get-version.ps1
  32. $packageSemVer = $versionObj.NuGetPackageVersion
  33. Write-Host "Building $packageSemVer" -Foreground Green
  34. New-Item -ItemType Directory -Force -Path $artifacts
  35. Write-Host "Building $scriptPath\System.Reactive.sln" -Foreground Green
  36. msbuild "$scriptPath\System.Reactive.sln" /restore /t:build /m /p:Configuration=$configuration /p:CreatePackage=true /p:NoPackageAnalysis=true
  37. if ($LastExitCode -ne 0) {
  38. Write-Host "Error with build" -Foreground Red
  39. if($isAppVeyor) {
  40. $host.SetShouldExit($LastExitCode)
  41. exit $LastExitCode
  42. }
  43. }
  44. Write-Host "Building Compat Package" -Foreground Green
  45. .\nuget.exe pack "$scriptPath\facades\System.Reactive.Compatibility.nuspec" -Version $packageSemVer -MinClientVersion 2.12 -nopackageanalysis -outputdirectory "$artifacts"
  46. if($hasSignClientSecret) {
  47. Write-Host "Signing Packages" -Foreground Green
  48. $nupgks = ls $artifacts\*React*.nupkg | Select -ExpandProperty FullName
  49. foreach ($nupkg in $nupgks) {
  50. Write-Host "Submitting $nupkg for signing"
  51. dotnet $signClientAppPath 'sign' -c $signClientSettings -i $nupkg -r $env:SignClientUser -s $env:SignClientSecret -n 'Rx.NET' -d 'Reactive Extensions for .NET' -u 'http://reactivex.io/'
  52. if ($LastExitCode -ne 0) {
  53. Write-Host "Error signing $nupkg" -Foreground Red
  54. if($isAppVeyor) {
  55. $host.SetShouldExit($LastExitCode)
  56. exit $LastExitCode
  57. }
  58. }
  59. Write-Host "Finished signing $nupkg"
  60. }
  61. } else {
  62. Write-Host "Client Secret not found, not signing packages"
  63. }
  64. Write-Host "Running tests" -Foreground Green
  65. $testDirectory = Join-Path $scriptPath "tests\Tests.System.Reactive"
  66. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  67. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  68. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe analyse /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --no-build --no-restore --filter `"SkipCI!=true`"" /Filters="+:module=System.Reactive;+:module=Microsoft.Reactive.Testing;+:module=System.Reactive.Observable.Aliases;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties
  69. #dotnet test $testDirectory --no-build --no-restore -c "Release" --filter "SkipCI!=true"
  70. if ($LastExitCode -ne 0) {
  71. Write-Host "Error with tests" -Foreground Red
  72. if($isAppVeyor) {
  73. $host.SetShouldExit($LastExitCode)
  74. exit $LastExitCode
  75. }
  76. }
  77. # Either display or publish the results
  78. if ($isAppVeyor -eq 'True')
  79. {
  80. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -f -p DotCover "$outputFile"
  81. }
  82. else
  83. {
  84. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  85. &"$outPutPath/index.htm"
  86. }