build-new.ps1 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. $xUnitConsolePath = ".\packages\xunit.runner.console\tools\xunit.console.exe"
  6. $rootPath = (Resolve-Path .).Path
  7. $artifacts = Join-Path $rootPath "artifacts"
  8. $signClientSettings = Join-Path (Join-Path (Get-Item $scriptPath).Parent.Parent.FullName "scripts") "SignClientSettings.json"
  9. $hasSignClientSecret = !([string]::IsNullOrEmpty($env:SignClientSecret))
  10. $signClientAppPath = Join-Path (Join-Path (Join-Path .\Packages "SignClient") "Tools") "SignClient.dll"
  11. #remove any old coverage file
  12. md -Force $outputLocation | Out-Null
  13. $outputPath = (Resolve-Path $outputLocation).Path
  14. $outputFileDotCover1 = Join-Path $outputPath -childpath 'coverage-ix1.dcvr'
  15. $outputFileDotCover2 = Join-Path $outputPath -childpath 'coverage-ix2.dcvr'
  16. $outputFileDotCover = Join-Path $outputPath -childpath 'coverage-ix.dcvr'
  17. $outputFile = Join-Path $outputPath -childpath 'coverage-ix.xml'
  18. Remove-Item $outputPath -Force -Recurse
  19. md -Force $outputLocation | Out-Null
  20. if (!(Test-Path .\nuget.exe)) {
  21. wget "https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe" -outfile .\nuget.exe
  22. }
  23. # get tools
  24. .\nuget.exe install -excludeversion SignClient -Version 0.5.0-beta4 -pre -outputdirectory packages
  25. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
  26. .\nuget.exe install -excludeversion gitversion.commandline -pre -outputdirectory packages
  27. .\nuget.exe install -excludeversion xunit.runner.console -pre -outputdirectory packages
  28. .\nuget.exe install -excludeversion ReportGenerator -outputdirectory packages
  29. #.\nuget.exe install -excludeversion coveralls.io -outputdirectory packages
  30. .\nuget.exe install -excludeversion coveralls.io.dotcover -outputdirectory packages
  31. .\packages\gitversion.commandline\tools\gitversion.exe /l console /output buildserver
  32. $versionObj = .\packages\gitversion.commandline\tools\gitversion.exe | ConvertFrom-Json
  33. $packageSemVer = $versionObj.FullSemVer
  34. New-Item -ItemType Directory -Force -Path $artifacts
  35. Write-Host "Restoring packages for $scriptPath\Ix.NET.sln" -Foreground Green
  36. .\nuget.exe restore "$scriptPath\Ix.NET.sln"
  37. Write-Host "Building $scriptPath\Ix.NET.sln" -Foreground Green
  38. msbuild "$scriptPath\Ix.NET.sln" /m /t:build /p:Configuration=$configuration
  39. Write-Host "Building Packages" -Foreground Green
  40. msbuild "$scriptPath\System.Interactive\System.Interactive.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  41. msbuild "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  42. msbuild "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  43. msbuild "$scriptPath\System.Interactive.Providers\System.Interactive.Providers.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  44. if($hasSignClientSecret) {
  45. Write-Host "Signing Packages" -Foreground Green
  46. $nupgks = ls $artifacts\*Interact*.nupkg | Select -ExpandProperty FullName
  47. foreach ($nupkg in $nupgks) {
  48. Write-Host "Submitting $nupkg for signing"
  49. dotnet $signClientAppPath 'zip' -c $signClientSettings -i $nupkg -s $env:SignClientSecret -n 'Ix.NET' -d 'Interactive Extensions for .NET' -u 'http://reactivex.io/'
  50. if ($LastExitCode -ne 0) {
  51. Write-Host "Error signing $nupkg" -Foreground Red
  52. if($isAppVeyor) {
  53. $host.SetShouldExit($LastExitCode)
  54. }
  55. }
  56. Write-Host "Finished signing $nupkg"
  57. }
  58. } else {
  59. Write-Host "Client Secret not found, not signing packages"
  60. }
  61. Write-Host "Running tests" -Foreground Green
  62. $testDirectory = Join-Path $scriptPath "Tests"
  63. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  64. # Run .NET Core only for now until perf improves on the runner for .net desktop
  65. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  66. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --no-build -f netcoreapp1.0" /output="$outputFileDotCover1" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"
  67. if ($LastExitCode -ne 0) {
  68. Write-Host "Error with tests" -Foreground Red
  69. if($isAppVeyor) {
  70. $host.SetShouldExit($LastExitCode)
  71. }
  72. }
  73. # run .net desktop tests
  74. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$xUnitConsolePath" /targetworkingdir="$testDirectory\bin\$configuration\net461\" /targetarguments="Tests.dll" /output="$outputFileDotCover2" /Filters="+:module=System.Interactive;+:module=System.Interactive.Async;+:module=System.Interactive.Providers;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute"
  75. if ($LastExitCode -ne 0) {
  76. Write-Host "Error with tests" -Foreground Red
  77. if($isAppVeyor) {
  78. $host.SetShouldExit($LastExitCode)
  79. }
  80. }
  81. # For perf, we need to use the xunit console runner, but that generates two reports. merge into one and generate the detailed xml output
  82. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe merge /Source="$outputFileDotCover1;$outputFileDotCover2" /Output="$outputFileDotCover"
  83. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties
  84. # Either display or publish the results
  85. if ($env:CI -eq 'True')
  86. {
  87. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -p DotCover "$outputFile"
  88. }
  89. else
  90. {
  91. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  92. &"$outPutPath/index.htm"
  93. }