build-new.ps1 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. $outputFileDotCover1 = Join-Path $outputPath -childpath 'coverage-rx1.dcvr'
  16. $outputFileDotCover2 = Join-Path $outputPath -childpath 'coverage-rx2.dcvr'
  17. $outputFileDotCover = Join-Path $outputPath -childpath 'coverage-rx.dcvr'
  18. $outputFile = Join-Path $outputPath -childpath 'coverage-rx.xml'
  19. Remove-Item $outputPath -Force -Recurse
  20. md -Force $outputLocation | Out-Null
  21. if (!(Test-Path .\nuget.exe)) {
  22. wget "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -outfile .\nuget.exe
  23. }
  24. # get tools
  25. .\nuget.exe install -excludeversion SignClient -Version 0.5.0-beta4 -pre -outputdirectory packages
  26. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
  27. .\nuget.exe install -excludeversion gitversion.commandline -pre -outputdirectory packages
  28. .\nuget.exe install -excludeversion xunit.runner.console -pre -outputdirectory packages
  29. #.\nuget.exe install -excludeversion OpenCover -Version 4.6.519 -outputdirectory packages
  30. .\nuget.exe install -excludeversion ReportGenerator -outputdirectory packages
  31. #.\nuget.exe install -excludeversion coveralls.io -outputdirectory packages
  32. .\nuget.exe install -excludeversion coveralls.io.dotcover -outputdirectory packages
  33. #update version
  34. .\packages\gitversion.commandline\tools\gitversion.exe /l console /output buildserver
  35. New-Item -ItemType Directory -Force -Path $artifacts
  36. Write-Host "Restoring packages for $scriptPath\System.Reactive.sln" -Foreground Green
  37. msbuild "$scriptPath\System.Reactive.sln" /m /t:restore /p:Configuration=$configuration
  38. Write-Host "Building $scriptPath\System.Reactive.sln" -Foreground Green
  39. msbuild "$scriptPath\System.Reactive.sln" /m /t:build /p:Configuration=$configuration
  40. Write-Host "Building Packages" -Foreground Green
  41. msbuild "$scriptPath\src\System.Reactive\System.Reactive.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  42. msbuild "$scriptPath\src\Microsoft.Reactive.Testing\Microsoft.Reactive.Testing.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  43. msbuild "$scriptPath\src\System.Reactive.Observable.Aliases\System.Reactive.Observable.Aliases.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  44. msbuild "$scriptPath\facades\System.Reactive.Core\System.Reactive.Core.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  45. msbuild "$scriptPath\facades\System.Reactive.Experimental\System.Reactive.Experimental.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  46. msbuild "$scriptPath\facades\System.Reactive.Interfaces\System.Reactive.Interfaces.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  47. msbuild "$scriptPath\facades\System.Reactive.Linq\System.Reactive.Linq.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  48. msbuild "$scriptPath\facades\System.Reactive.PlatformServices\System.Reactive.PlatformServices.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  49. msbuild "$scriptPath\facades\System.Reactive.Providers\System.Reactive.Providers.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  50. msbuild "$scriptPath\facades\System.Reactive.Runtime.Remoting\System.Reactive.Runtime.Remoting.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  51. msbuild "$scriptPath\facades\System.Reactive.Windows.Forms\System.Reactive.Windows.Forms.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  52. msbuild "$scriptPath\facades\System.Reactive.Windows.Threading\System.Reactive.Windows.Threading.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  53. msbuild "$scriptPath\facades\System.Reactive.WindowsRuntime\System.Reactive.WindowsRuntime.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  54. if($hasSignClientSecret) {
  55. Write-Host "Signing Packages" -Foreground Green
  56. $nupgks = ls $artifacts\*React*.nupkg | Select -ExpandProperty FullName
  57. foreach ($nupkg in $nupgks) {
  58. Write-Host "Submitting $nupkg for signing"
  59. dotnet $signClientAppPath 'zip' -c $signClientSettings -i $nupkg -s $env:SignClientSecret -n 'Rx.NET' -d 'Reactive Extensions for .NET' -u 'http://reactivex.io/'
  60. if ($LastExitCode -ne 0) {
  61. Write-Host "Error signing $nupkg" -Foreground Red
  62. if($isAppVeyor) {
  63. $host.SetShouldExit($LastExitCode)
  64. }
  65. }
  66. Write-Host "Finished signing $nupkg"
  67. }
  68. } else {
  69. Write-Host "Client Secret not found, not signing packages"
  70. }
  71. Write-Host "Running tests" -Foreground Green
  72. $testDirectory = Join-Path $scriptPath "tests\Tests.System.Reactive"
  73. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  74. # Run .NET Core only for now until perf improves on the runner for .net desktop
  75. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  76. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --no-build -f netcoreapp1.0 --filter:SkipCI!=true" /output="$outputFileDotCover1" /Filters="+:module=System.Reactive;+:module=Microsoft.Reactive.Testing;+:module=System.Reactive.Observable.Aliases;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode
  77. if ($LastExitCode -ne 0) {
  78. Write-Host "Error with tests" -Foreground Red
  79. if($isAppVeyor) {
  80. $host.SetShouldExit($LastExitCode)
  81. }
  82. }
  83. # run .net desktop tests
  84. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$xUnitConsolePath" /targetworkingdir="$testDirectory\bin\$configuration\net46\" /targetarguments="Tests.System.Reactive.dll -notrait SkipCI=true" /output="$outputFileDotCover2" /Filters="+:module=System.Reactive;+:module=Microsoft.Reactive.Testing;+:module=System.Reactive.Observable.Aliases;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode
  85. if ($LastExitCode -ne 0) {
  86. Write-Host "Error with tests" -Foreground Red
  87. if($isAppVeyor) {
  88. $host.SetShouldExit($LastExitCode)
  89. }
  90. }
  91. #.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe analyze /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --no-build --filter:SkipCI!=true" /ReportType=DetailedXML /output="$outputFile" /Filters="+:module=System.Reactive;+:module=Microsoft.Reactive.Testing;+:module=System.Reactive.Observable.Aliases;-:type=Xunit*" /DisableDefaultFilters /HideAutoProperties /ReturnTargetExitCode
  92. # For perf, we need to use the xunit console runner, but that generates two reports. merge into one and generate the detailed xml output
  93. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe merge /Source="$outputFileDotCover1;$outputFileDotCover2" /Output="$outputFileDotCover"
  94. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties
  95. # Either display or publish the results
  96. if ($env:CI -eq 'True')
  97. {
  98. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -p DotCover "$outputFile" --full-sources
  99. }
  100. else
  101. {
  102. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  103. &"$outPutPath/index.htm"
  104. }