build-new.ps1 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. $outputFileDotCover = Join-Path $outputPath -childpath 'coverage-rx.dcvr'
  16. $outputFile = Join-Path $outputPath -childpath 'coverage-rx.xml'
  17. Remove-Item $outputPath -Force -Recurse
  18. md -Force $outputLocation | Out-Null
  19. if (!(Test-Path .\nuget.exe)) {
  20. wget "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -outfile .\nuget.exe
  21. }
  22. # get tools
  23. .\nuget.exe install -excludeversion SignClient -Version 0.5.0-beta4 -pre -outputdirectory packages
  24. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
  25. .\nuget.exe install -excludeversion gitversion.commandline -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. #update version
  30. # .\packages\gitversion.commandline\tools\gitversion.exe /l console /output buildserver
  31. New-Item -ItemType Directory -Force -Path $artifacts
  32. Write-Host "Restoring packages for $scriptPath\System.Reactive.sln" -Foreground Green
  33. msbuild "$scriptPath\System.Reactive.sln" /m /t:restore /p:Configuration=$configuration
  34. Write-Host "Building $scriptPath\System.Reactive.sln" -Foreground Green
  35. msbuild "$scriptPath\System.Reactive.sln" /m /t:build /p:Configuration=$configuration
  36. Write-Host "Building Packages" -Foreground Green
  37. msbuild "$scriptPath\src\System.Reactive\System.Reactive.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  38. msbuild "$scriptPath\src\Microsoft.Reactive.Testing\Microsoft.Reactive.Testing.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  39. msbuild "$scriptPath\src\System.Reactive.Observable.Aliases\System.Reactive.Observable.Aliases.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  40. msbuild "$scriptPath\facades\System.Reactive.Core\System.Reactive.Core.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  41. msbuild "$scriptPath\facades\System.Reactive.Experimental\System.Reactive.Experimental.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  42. msbuild "$scriptPath\facades\System.Reactive.Interfaces\System.Reactive.Interfaces.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  43. msbuild "$scriptPath\facades\System.Reactive.Linq\System.Reactive.Linq.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  44. msbuild "$scriptPath\facades\System.Reactive.PlatformServices\System.Reactive.PlatformServices.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  45. msbuild "$scriptPath\facades\System.Reactive.Providers\System.Reactive.Providers.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  46. msbuild "$scriptPath\facades\System.Reactive.Runtime.Remoting\System.Reactive.Runtime.Remoting.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  47. msbuild "$scriptPath\facades\System.Reactive.Windows.Forms\System.Reactive.Windows.Forms.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  48. 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"
  49. msbuild "$scriptPath\facades\System.Reactive.WindowsRuntime\System.Reactive.WindowsRuntime.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true /p:NuGetBuildTasksPackTargets="workaround"
  50. if($hasSignClientSecret) {
  51. Write-Host "Signing Packages" -Foreground Green
  52. $nupgks = ls $artifacts\*React*.nupkg | Select -ExpandProperty FullName
  53. foreach ($nupkg in $nupgks) {
  54. Write-Host "Submitting $nupkg for signing"
  55. dotnet $signClientAppPath 'zip' -c $signClientSettings -i $nupkg -s $env:SignClientSecret -n 'Rx.NET' -d 'Reactive Extensions for .NET' -u 'http://reactivex.io/'
  56. if ($LastExitCode -ne 0) {
  57. Write-Host "Error signing $nupkg" -Foreground Red
  58. if($isAppVeyor) {
  59. $host.SetShouldExit($LastExitCode)
  60. }
  61. }
  62. Write-Host "Finished signing $nupkg"
  63. }
  64. } else {
  65. Write-Host "Client Secret not found, not signing packages"
  66. }
  67. Write-Host "Running tests" -Foreground Green
  68. $testDirectory = Join-Path $scriptPath "tests\Tests.System.Reactive"
  69. # OpenCover and Coveralls isn't working currently. So run tests on CI and coverage with JetBrains locally
  70. if($env:CI -eq 'True')
  71. {
  72. dotnet test "$testDirectory\Tests.System.Reactive.csproj" -c $configuration --no-build --filter:SkipCI!=true
  73. }
  74. else
  75. {
  76. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  77. #.\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="c:\program files\dotnet\dotnet.exe" /targetworkingdir=".\Tests.System.Reactive" /targetarguments="test --no-build --filter:SkipCI!=true" /output=.\testResults.dvcr /Filters="+:module=System.Reactive;+:module=Microsoft.Reactive.Testing;+:module=System.Reactive.Observable.Aliases;-:type=Xunit*" /DisableDefaultFilters
  78. .\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
  79. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  80. &"$outPutPath/index.htm"
  81. }
  82. if ($LastExitCode -ne 0) {
  83. Write-Host "Error with tests" -Foreground Red
  84. if($isAppVeyor) {
  85. $host.SetShouldExit($LastExitCode)
  86. }
  87. }
  88. # We bail out here because OpenCover isn't properly reporting coverage
  89. exit
  90. # Execute OpenCover with a target of "dotnet test"
  91. # & $openCoverPath -register:user -oldStyle -mergeoutput -target:dotnet.exe -targetdir:"$testDirectory" -targetargs:"test --no-build --filter:SkipCI!=true" -output:"$outputFile" -skipautoprops -returntargetcode -excludebyattribute:"System.Diagnostics.DebuggerNonUserCodeAttribute;System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" -nodefaultfilters -hideskipped:All -filter:"+[*]* -[*.Tests]* -[Tests.*]* -[xunit.*]* -[*]Xunit.*"
  92. # Either display or publish the results
  93. if ($env:CI -eq 'True')
  94. {
  95. .\packages\coveralls.io\tools\coveralls.net.exe --opencover "$outputFile" --full-sources
  96. }
  97. else
  98. {
  99. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  100. &$outPutPath/index.htm
  101. }