build-new.ps1 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.0.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.4-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. msbuild "$scriptPath\Ix.NET.sln" /m /t:restore /p:Configuration=$configuration
  40. # Force a restore again to get proper version numbers https://github.com/NuGet/Home/issues/4337
  41. msbuild "$scriptPath\Ix.NET.sln" /m /t:restore /p:Configuration=$configuration
  42. Write-Host "Building $scriptPath\Ix.NET.sln" -Foreground Green
  43. msbuild "$scriptPath\Ix.NET.sln" /m /t:build /p:Configuration=$configuration
  44. if ($LastExitCode -ne 0) {
  45. Write-Host "Error with build" -Foreground Red
  46. if($isAppVeyor) {
  47. $host.SetShouldExit($LastExitCode)
  48. exit $LastExitCode
  49. }
  50. }
  51. Write-Host "Building Packages" -Foreground Green
  52. msbuild "$scriptPath\System.Interactive\System.Interactive.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  53. msbuild "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  54. msbuild "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  55. msbuild "$scriptPath\System.Interactive.Providers\System.Interactive.Providers.csproj" /t:pack /p:Configuration=$configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  56. if($hasSignClientSecret) {
  57. Write-Host "Signing Packages" -Foreground Green
  58. $nupgks = ls $artifacts\*Interact*.nupkg | Select -ExpandProperty FullName
  59. foreach ($nupkg in $nupgks) {
  60. Write-Host "Submitting $nupkg for signing"
  61. dotnet $signClientAppPath 'sign' -c $signClientSettings -i $nupkg -s $env:SignClientSecret -n 'Ix.NET' -d 'Interactive Extensions for .NET' -u 'http://reactivex.io/'
  62. if ($LastExitCode -ne 0) {
  63. Write-Host "Error signing $nupkg" -Foreground Red
  64. if($isAppVeyor) {
  65. $host.SetShouldExit($LastExitCode)
  66. exit $LastExitCode
  67. }
  68. }
  69. Write-Host "Finished signing $nupkg"
  70. }
  71. } else {
  72. Write-Host "Client Secret not found, not signing packages"
  73. }
  74. Write-Host "Running tests" -Foreground Green
  75. $testDirectory = Join-Path $scriptPath "Tests"
  76. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  77. # Run .NET Core only for now until perf improves on the runner for .net desktop
  78. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  79. .\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"
  80. if ($LastExitCode -ne 0) {
  81. Write-Host "Error with tests" -Foreground Red
  82. if($isAppVeyor) {
  83. $host.SetShouldExit($LastExitCode)
  84. exit $LastExitCode
  85. }
  86. }
  87. # run .net desktop tests
  88. .\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"
  89. if ($LastExitCode -ne 0) {
  90. Write-Host "Error with tests" -Foreground Red
  91. if($isAppVeyor) {
  92. $host.SetShouldExit($LastExitCode)
  93. exit $LastExitCode
  94. }
  95. }
  96. # For perf, we need to use the xunit console runner, but that generates two reports. merge into one and generate the detailed xml output
  97. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe merge /Source="$outputFileDotCover1;$outputFileDotCover2" /Output="$outputFileDotCover"
  98. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties
  99. # Either display or publish the results
  100. if ($env:CI -eq 'True')
  101. {
  102. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -p DotCover "$outputFile"
  103. }
  104. else
  105. {
  106. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  107. &"$outPutPath/index.htm"
  108. }