build-new.ps1 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. $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.7.0 -outputdirectory packages
  23. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
  24. .\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.0.37-beta -pre -outputdirectory packages
  25. .\nuget.exe install -excludeversion xunit.runner.console -pre -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 "Restoring packages for $scriptPath\System.Reactive.sln" -Foreground Green
  36. msbuild "$scriptPath\System.Reactive.sln" /m /t:restore /p:Configuration=$configuration
  37. # Force a restore again to get proper version numbers https://github.com/NuGet/Home/issues/4337
  38. msbuild "$scriptPath\System.Reactive.sln" /m /t:restore /p:Configuration=$configuration
  39. Write-Host "Building $scriptPath\System.Reactive.sln" -Foreground Green
  40. msbuild "$scriptPath\System.Reactive.sln" /t:build /m /p:Configuration=$configuration
  41. if ($LastExitCode -ne 0) {
  42. Write-Host "Error with build" -Foreground Red
  43. if($isAppVeyor) {
  44. $host.SetShouldExit($LastExitCode)
  45. exit $LastExitCode
  46. }
  47. }
  48. Write-Host "Building Packages" -Foreground Green
  49. msbuild "$scriptPath\src\System.Reactive\System.Reactive.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  50. msbuild "$scriptPath\src\Microsoft.Reactive.Testing\Microsoft.Reactive.Testing.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  51. msbuild "$scriptPath\src\System.Reactive.Observable.Aliases\System.Reactive.Observable.Aliases.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  52. msbuild "$scriptPath\facades\System.Reactive.Core\System.Reactive.Core.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  53. msbuild "$scriptPath\facades\System.Reactive.Experimental\System.Reactive.Experimental.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  54. msbuild "$scriptPath\facades\System.Reactive.Interfaces\System.Reactive.Interfaces.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  55. msbuild "$scriptPath\facades\System.Reactive.Linq\System.Reactive.Linq.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  56. msbuild "$scriptPath\facades\System.Reactive.PlatformServices\System.Reactive.PlatformServices.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  57. msbuild "$scriptPath\facades\System.Reactive.Providers\System.Reactive.Providers.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  58. msbuild "$scriptPath\facades\System.Reactive.Runtime.Remoting\System.Reactive.Runtime.Remoting.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  59. msbuild "$scriptPath\facades\System.Reactive.Windows.Forms\System.Reactive.Windows.Forms.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  60. msbuild "$scriptPath\facades\System.Reactive.Windows.Threading\System.Reactive.Windows.Threading.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  61. msbuild "$scriptPath\facades\System.Reactive.WindowsRuntime\System.Reactive.WindowsRuntime.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  62. .\nuget.exe pack "$scriptPath\facades\System.Reactive.Compatibility.nuspec" -Version $packageSemVer -MinClientVersion 2.12 -nopackageanalysis -outputdirectory "$artifacts"
  63. if($hasSignClientSecret) {
  64. Write-Host "Signing Packages" -Foreground Green
  65. $nupgks = ls $artifacts\*React*.nupkg | Select -ExpandProperty FullName
  66. foreach ($nupkg in $nupgks) {
  67. Write-Host "Submitting $nupkg for signing"
  68. dotnet $signClientAppPath 'sign' -c $signClientSettings -i $nupkg -s $env:SignClientSecret -n 'Rx.NET' -d 'Reactive Extensions for .NET' -u 'http://reactivex.io/'
  69. if ($LastExitCode -ne 0) {
  70. Write-Host "Error signing $nupkg" -Foreground Red
  71. if($isAppVeyor) {
  72. $host.SetShouldExit($LastExitCode)
  73. exit $LastExitCode
  74. }
  75. }
  76. Write-Host "Finished signing $nupkg"
  77. }
  78. } else {
  79. Write-Host "Client Secret not found, not signing packages"
  80. }
  81. Write-Host "Running tests" -Foreground Green
  82. $testDirectory = Join-Path $scriptPath "tests\Tests.System.Reactive"
  83. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  84. # Use xUnit CLI as it's significantly faster than vstest (dotnet test)
  85. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  86. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe analyse /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration --no-build -notrait `"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
  87. if ($LastExitCode -ne 0) {
  88. Write-Host "Error with tests" -Foreground Red
  89. if($isAppVeyor) {
  90. $host.SetShouldExit($LastExitCode)
  91. exit $LastExitCode
  92. }
  93. }
  94. # Either display or publish the results
  95. if ($env:CI -eq 'True')
  96. {
  97. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -f -p DotCover "$outputFile"
  98. }
  99. else
  100. {
  101. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  102. &"$outPutPath/index.htm"
  103. }