build-new.ps1 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 = 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.3.0/nuget.exe" -outfile .\nuget.exe
  22. }
  23. # get tools
  24. .\nuget.exe install -excludeversion SignClient -Version 0.7.0 -outputdirectory packages
  25. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
  26. .\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.0.37-beta -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. #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.Providers\System.Interactive.Providers.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.Linq.Async\System.Linq.Async.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.Linq.Async.Queryable\System.Linq.Async.Queryable.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. dotnet pack "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  79. if ($LastExitCode -ne 0) {
  80. Write-Host "Error with build" -Foreground Red
  81. if($isAppVeyor) {
  82. $host.SetShouldExit($LastExitCode)
  83. exit $LastExitCode
  84. }
  85. }
  86. dotnet pack "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  87. if ($LastExitCode -ne 0) {
  88. Write-Host "Error with build" -Foreground Red
  89. if($isAppVeyor) {
  90. $host.SetShouldExit($LastExitCode)
  91. exit $LastExitCode
  92. }
  93. }
  94. if($hasSignClientSecret) {
  95. Write-Host "Signing Packages" -Foreground Green
  96. $nupgks = ls $artifacts\*Interact*.nupkg | Select -ExpandProperty FullName
  97. foreach ($nupkg in $nupgks) {
  98. Write-Host "Submitting $nupkg for signing"
  99. dotnet $signClientAppPath 'sign' -c $signClientSettings -i $nupkg -s $env:SignClientSecret -n 'Ix.NET' -d 'Interactive Extensions for .NET' -u 'http://reactivex.io/'
  100. if ($LastExitCode -ne 0) {
  101. Write-Host "Error signing $nupkg" -Foreground Red
  102. if($isAppVeyor) {
  103. $host.SetShouldExit($LastExitCode)
  104. exit $LastExitCode
  105. }
  106. }
  107. Write-Host "Finished signing $nupkg"
  108. }
  109. } else {
  110. Write-Host "Client Secret not found, not signing packages"
  111. }
  112. Write-Host "Running tests" -Foreground Green
  113. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  114. # Use xUnit CLI as it's significantly faster than vstest (dotnet test)
  115. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  116. $testDirectory = Join-Path $scriptPath "System.Interactive.Tests"
  117. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover1"
  118. if ($LastExitCode -ne 0) {
  119. Write-Host "Error with tests" -Foreground Red
  120. if($isAppVeyor) {
  121. $host.SetShouldExit($LastExitCode)
  122. exit $LastExitCode
  123. }
  124. }
  125. $testDirectory = Join-Path $scriptPath "System.Linq.Async.Tests"
  126. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2"
  127. if ($LastExitCode -ne 0) {
  128. Write-Host "Error with tests" -Foreground Red
  129. if($isAppVeyor) {
  130. $host.SetShouldExit($LastExitCode)
  131. exit $LastExitCode
  132. }
  133. }
  134. $testDirectory = Join-Path $scriptPath "System.Interactive.Async.Tests"
  135. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2"
  136. if ($LastExitCode -ne 0) {
  137. Write-Host "Error with tests" -Foreground Red
  138. if($isAppVeyor) {
  139. $host.SetShouldExit($LastExitCode)
  140. exit $LastExitCode
  141. }
  142. }
  143. $testDirectory = Join-Path $scriptPath "System.Interactive.Async.Providers.Tests"
  144. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="xunit -c $configuration" /Filters="+:module=System.Interactive;+:module=System.Interactive.Providers;+:module=System.Linq.Async;+:module=System.Linq.Async.Queryable;+:module=System.Interactive.Async;+:module=System.Interactive.Async.Providers;-:type=Xunit*" /DisableDefaultFilters /ReturnTargetExitCode /AttributeFilters="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" /output="$outputFileDotCover2"
  145. if ($LastExitCode -ne 0) {
  146. Write-Host "Error with tests" -Foreground Red
  147. if($isAppVeyor) {
  148. $host.SetShouldExit($LastExitCode)
  149. exit $LastExitCode
  150. }
  151. }
  152. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe merge /Source="$outputFileDotCover1;$outputFileDotCover2" /Output="$outputFileDotCover"
  153. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties
  154. # Either display or publish the results
  155. if ($env:CI -eq 'True')
  156. {
  157. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -p DotCover "$outputFile"
  158. }
  159. else
  160. {
  161. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  162. &"$outPutPath/index.htm"
  163. }