build-new.ps1 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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\net452\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 = ".\packages\SignClient\tools\netcoreapp2.0\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/latest/nuget.exe" -outfile .\nuget.exe
  22. }
  23. # get tools
  24. .\nuget.exe install -excludeversion SignClient -Version 0.9.0 -outputdirectory packages
  25. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
  26. .\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.0.41 -outputdirectory packages
  27. .\nuget.exe install -excludeversion xunit.runner.console -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. #update version
  32. $versionObj = .\packages\Nerdbank.GitVersioning\tools\get-version.ps1
  33. $packageSemVer = $versionObj.NuGetPackageVersion
  34. Write-Host "Building $packageSemVer" -Foreground Green
  35. New-Item -ItemType Directory -Force -Path $artifacts
  36. Write-Host "Restoring packages for $scriptPath\Ix.NET.sln" -Foreground Green
  37. # use nuget.exe to restore on the legacy proj type
  38. #.\nuget.exe restore "$scriptPath\System.Interactive.Tests.Uwp.DeviceRunner\System.Interactive.Tests.Uwp.DeviceRunner.csproj"
  39. dotnet restore "$scriptPath\Ix.NET.sln"
  40. # Force a restore again to get proper version numbers https://github.com/NuGet/Home/issues/4337
  41. dotnet restore "$scriptPath\Ix.NET.sln"
  42. Write-Host "Building $scriptPath\Ix.NET.sln" -Foreground Green
  43. # Using MSBuild here since th UWP test project cannot be built by the dotnet CLI
  44. #msbuild "$scriptPath\Ix.NET.sln" /m /t:build /p:Configuration=$configuration
  45. Write-Host "Building Packages" -Foreground Green
  46. dotnet pack "$scriptPath\System.Interactive\System.Interactive.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  47. if ($LastExitCode -ne 0) {
  48. Write-Host "Error with build" -Foreground Red
  49. if($isAppVeyor) {
  50. $host.SetShouldExit($LastExitCode)
  51. exit $LastExitCode
  52. }
  53. }
  54. dotnet pack "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  55. if ($LastExitCode -ne 0) {
  56. Write-Host "Error with build" -Foreground Red
  57. if($isAppVeyor) {
  58. $host.SetShouldExit($LastExitCode)
  59. exit $LastExitCode
  60. }
  61. }
  62. dotnet pack "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  63. if ($LastExitCode -ne 0) {
  64. Write-Host "Error with build" -Foreground Red
  65. if($isAppVeyor) {
  66. $host.SetShouldExit($LastExitCode)
  67. exit $LastExitCode
  68. }
  69. }
  70. dotnet pack "$scriptPath\System.Interactive.Providers\System.Interactive.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  71. if ($LastExitCode -ne 0) {
  72. Write-Host "Error with build" -Foreground Red
  73. if($isAppVeyor) {
  74. $host.SetShouldExit($LastExitCode)
  75. exit $LastExitCode
  76. }
  77. }
  78. if($hasSignClientSecret) {
  79. Write-Host "Signing Packages" -Foreground Green
  80. $nupgks = ls $artifacts\*Interact*.nupkg | Select -ExpandProperty FullName
  81. foreach ($nupkg in $nupgks) {
  82. Write-Host "Submitting $nupkg for signing"
  83. dotnet $signClientAppPath 'sign' -c $signClientSettings -i $nupkg -r $env:SignClientUser -s $env:SignClientSecret -n 'Ix.NET' -d 'Interactive Extensions for .NET' -u 'http://reactivex.io/'
  84. if ($LastExitCode -ne 0) {
  85. Write-Host "Error signing $nupkg" -Foreground Red
  86. if($isAppVeyor) {
  87. $host.SetShouldExit($LastExitCode)
  88. exit $LastExitCode
  89. }
  90. }
  91. Write-Host "Finished signing $nupkg"
  92. }
  93. } else {
  94. Write-Host "Client Secret not found, not signing packages"
  95. }
  96. Write-Host "Running tests" -Foreground Green
  97. $testDirectory = Join-Path $scriptPath "System.Interactive.Tests"
  98. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  99. # Use xUnit CLI as it's significantly faster than vstest (dotnet test)
  100. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  101. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /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" /output="$outputFileDotCover1"
  102. if ($LastExitCode -ne 0) {
  103. Write-Host "Error with tests" -Foreground Red
  104. if($isAppVeyor) {
  105. $host.SetShouldExit($LastExitCode)
  106. exit $LastExitCode
  107. }
  108. }
  109. $testDirectory = Join-Path $scriptPath "System.Interactive.Async.Tests"
  110. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /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" /output="$outputFileDotCover2"
  111. if ($LastExitCode -ne 0) {
  112. Write-Host "Error with tests" -Foreground Red
  113. if($isAppVeyor) {
  114. $host.SetShouldExit($LastExitCode)
  115. exit $LastExitCode
  116. }
  117. }
  118. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe merge /Source="$outputFileDotCover1;$outputFileDotCover2" /Output="$outputFileDotCover"
  119. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties
  120. # Either display or publish the results
  121. if ($env:CI -eq 'True')
  122. {
  123. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -p DotCover "$outputFile"
  124. }
  125. else
  126. {
  127. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  128. &"$outPutPath/index.htm"
  129. }