build-new.ps1 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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\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 = 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.7.0 -outputdirectory packages
  26. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
  27. .\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.0.3-beta-g4d80666c50 -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. $versionObj = .\packages\Nerdbank.GitVersioning\tools\get-version.ps1
  35. $packageSemVer = $versionObj.NuGetPackageVersion
  36. Write-Host "Building $packageSemVer" -Foreground Green
  37. New-Item -ItemType Directory -Force -Path $artifacts
  38. Write-Host "Restoring packages for $scriptPath\System.Reactive.sln" -Foreground Green
  39. msbuild "$scriptPath\System.Reactive.sln" /m /t:restore /p:Configuration=$configuration
  40. # Force a restore again to get proper version numbers https://github.com/NuGet/Home/issues/4337
  41. msbuild "$scriptPath\System.Reactive.sln" /m /t:restore /p:Configuration=$configuration
  42. Write-Host "Building $scriptPath\System.Reactive.sln" -Foreground Green
  43. msbuild "$scriptPath\System.Reactive.sln" /t:build /m /p:Configuration=$configuration
  44. if ($LastExitCode -ne 0) {
  45. Write-Host "Error with build" -Foreground Red
  46. if($isAppVeyor) {
  47. $host.SetShouldExit($LastExitCode)
  48. exit $LastExitCode
  49. }
  50. }
  51. Write-Host "Building Packages" -Foreground Green
  52. msbuild "$scriptPath\src\System.Reactive\System.Reactive.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  53. msbuild "$scriptPath\src\Microsoft.Reactive.Testing\Microsoft.Reactive.Testing.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  54. msbuild "$scriptPath\src\System.Reactive.Observable.Aliases\System.Reactive.Observable.Aliases.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  55. msbuild "$scriptPath\facades\System.Reactive.Core\System.Reactive.Core.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  56. msbuild "$scriptPath\facades\System.Reactive.Experimental\System.Reactive.Experimental.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  57. msbuild "$scriptPath\facades\System.Reactive.Interfaces\System.Reactive.Interfaces.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  58. msbuild "$scriptPath\facades\System.Reactive.Linq\System.Reactive.Linq.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  59. msbuild "$scriptPath\facades\System.Reactive.PlatformServices\System.Reactive.PlatformServices.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  60. msbuild "$scriptPath\facades\System.Reactive.Providers\System.Reactive.Providers.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  61. msbuild "$scriptPath\facades\System.Reactive.Runtime.Remoting\System.Reactive.Runtime.Remoting.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  62. msbuild "$scriptPath\facades\System.Reactive.Windows.Forms\System.Reactive.Windows.Forms.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  63. 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"
  64. msbuild "$scriptPath\facades\System.Reactive.WindowsRuntime\System.Reactive.WindowsRuntime.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  65. .\nuget.exe pack "$scriptPath\facades\System.Reactive.Compatibility.nuspec" -Version $packageSemVer -MinClientVersion 2.12 -nopackageanalysis -outputdirectory "$artifacts"
  66. if($hasSignClientSecret) {
  67. Write-Host "Signing Packages" -Foreground Green
  68. $nupgks = ls $artifacts\*React*.nupkg | Select -ExpandProperty FullName
  69. foreach ($nupkg in $nupgks) {
  70. Write-Host "Submitting $nupkg for signing"
  71. dotnet $signClientAppPath 'sign' -c $signClientSettings -i $nupkg -s $env:SignClientSecret -n 'Rx.NET' -d 'Reactive Extensions for .NET' -u 'http://reactivex.io/'
  72. if ($LastExitCode -ne 0) {
  73. Write-Host "Error signing $nupkg" -Foreground Red
  74. if($isAppVeyor) {
  75. $host.SetShouldExit($LastExitCode)
  76. exit $LastExitCode
  77. }
  78. }
  79. Write-Host "Finished signing $nupkg"
  80. }
  81. } else {
  82. Write-Host "Client Secret not found, not signing packages"
  83. }
  84. Write-Host "Running tests" -Foreground Green
  85. $testDirectory = Join-Path $scriptPath "tests\Tests.System.Reactive"
  86. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  87. # Run .NET Core only for now until perf improves on the runner for .net desktop
  88. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  89. .\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 /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"
  90. if ($LastExitCode -ne 0) {
  91. Write-Host "Error with tests" -Foreground Red
  92. if($isAppVeyor) {
  93. $host.SetShouldExit($LastExitCode)
  94. exit $LastExitCode
  95. }
  96. }
  97. # run .net desktop tests
  98. .\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 /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"
  99. if ($LastExitCode -ne 0) {
  100. Write-Host "Error with tests" -Foreground Red
  101. if($isAppVeyor) {
  102. $host.SetShouldExit($LastExitCode)
  103. exit $LastExitCode
  104. }
  105. }
  106. #.\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
  107. # For perf, we need to use the xunit console runner, but that generates two reports. merge into one and generate the detailed xml output
  108. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe merge /Source="$outputFileDotCover1;$outputFileDotCover2" /Output="$outputFileDotCover"
  109. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties
  110. # Either display or publish the results
  111. if ($env:CI -eq 'True')
  112. {
  113. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -f -p DotCover "$outputFile"
  114. }
  115. else
  116. {
  117. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  118. &"$outPutPath/index.htm"
  119. }