build-new.ps1 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 /bl:.\artifacts\build.binlog /p:RestoreAdditionalProjectFallbackFolders=""
  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 Packages" -Foreground Green
  45. msbuild "$scriptPath\src\System.Reactive.Interfaces\System.Reactive.Interfaces.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  46. msbuild "$scriptPath\src\System.Reactive\System.Reactive.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  47. msbuild "$scriptPath\src\Microsoft.Reactive.Testing\Microsoft.Reactive.Testing.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  48. msbuild "$scriptPath\src\System.Reactive.Observable.Aliases\System.Reactive.Observable.Aliases.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  49. msbuild "$scriptPath\facades\System.Reactive.Core\System.Reactive.Core.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  50. msbuild "$scriptPath\facades\System.Reactive.Experimental\System.Reactive.Experimental.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  51. msbuild "$scriptPath\facades\System.Reactive.Linq\System.Reactive.Linq.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  52. msbuild "$scriptPath\facades\System.Reactive.PlatformServices\System.Reactive.PlatformServices.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  53. msbuild "$scriptPath\facades\System.Reactive.Providers\System.Reactive.Providers.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  54. msbuild "$scriptPath\facades\System.Reactive.Runtime.Remoting\System.Reactive.Runtime.Remoting.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  55. msbuild "$scriptPath\facades\System.Reactive.Windows.Forms\System.Reactive.Windows.Forms.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  56. msbuild "$scriptPath\facades\System.Reactive.Windows.Threading\System.Reactive.Windows.Threading.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  57. msbuild "$scriptPath\facades\System.Reactive.WindowsRuntime\System.Reactive.WindowsRuntime.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  58. .\nuget.exe pack "$scriptPath\facades\System.Reactive.Compatibility.nuspec" -Version $packageSemVer -MinClientVersion 2.12 -nopackageanalysis -outputdirectory "$artifacts"
  59. if($hasSignClientSecret) {
  60. Write-Host "Signing Packages" -Foreground Green
  61. $nupgks = ls $artifacts\*React*.nupkg | Select -ExpandProperty FullName
  62. foreach ($nupkg in $nupgks) {
  63. Write-Host "Submitting $nupkg for signing"
  64. 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/'
  65. if ($LastExitCode -ne 0) {
  66. Write-Host "Error signing $nupkg" -Foreground Red
  67. if($isAppVeyor) {
  68. $host.SetShouldExit($LastExitCode)
  69. exit $LastExitCode
  70. }
  71. }
  72. Write-Host "Finished signing $nupkg"
  73. }
  74. } else {
  75. Write-Host "Client Secret not found, not signing packages"
  76. }
  77. Write-Host "Running tests" -Foreground Green
  78. $testDirectory = Join-Path $scriptPath "tests\Tests.System.Reactive"
  79. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  80. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  81. .\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
  82. #dotnet test $testDirectory --no-build --no-restore -c "Release" --filter "SkipCI!=true"
  83. if ($LastExitCode -ne 0) {
  84. Write-Host "Error with tests" -Foreground Red
  85. if($isAppVeyor) {
  86. $host.SetShouldExit($LastExitCode)
  87. exit $LastExitCode
  88. }
  89. }
  90. # Either display or publish the results
  91. if ($isAppVeyor -eq 'True')
  92. {
  93. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -f -p DotCover "$outputFile"
  94. }
  95. else
  96. {
  97. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  98. &"$outPutPath/index.htm"
  99. }