build-new.ps1 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. $outputFile = Join-Path $outputPath -childpath 'coverage-ix.xml'
  15. Remove-Item $outputPath -Force -Recurse
  16. md -Force $outputLocation | Out-Null
  17. if (!(Test-Path .\nuget.exe)) {
  18. wget "https://dist.nuget.org/win-x86-commandline/v4.1.0/nuget.exe" -outfile .\nuget.exe
  19. }
  20. # get tools
  21. .\nuget.exe install -excludeversion SignClient -Version 0.7.0 -outputdirectory packages
  22. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
  23. .\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.0.21-beta -pre -outputdirectory packages
  24. .\nuget.exe install -excludeversion xunit.runner.console -pre -outputdirectory packages
  25. .\nuget.exe install -excludeversion ReportGenerator -outputdirectory packages
  26. #.\nuget.exe install -excludeversion coveralls.io -outputdirectory packages
  27. .\nuget.exe install -excludeversion coveralls.io.dotcover -outputdirectory packages
  28. #update version
  29. $versionObj = .\packages\Nerdbank.GitVersioning\tools\get-version.ps1
  30. $packageSemVer = $versionObj.NuGetPackageVersion
  31. Write-Host "Building $packageSemVer" -Foreground Green
  32. New-Item -ItemType Directory -Force -Path $artifacts
  33. Write-Host "Restoring packages for $scriptPath\Ix.NET.sln" -Foreground Green
  34. # use nuget.exe to restore on the legacy proj type
  35. #.\nuget.exe restore "$scriptPath\System.Interactive.Tests.Uwp.DeviceRunner\System.Interactive.Tests.Uwp.DeviceRunner.csproj"
  36. dotnet restore "$scriptPath\Ix.NET.sln" -c $configuration
  37. # Force a restore again to get proper version numbers https://github.com/NuGet/Home/issues/4337
  38. dotnet restore "$scriptPath\Ix.NET.sln"
  39. Write-Host "Building $scriptPath\Ix.NET.sln" -Foreground Green
  40. # Using MSBuild here since th UWP test project cannot be built by the dotnet CLI
  41. #msbuild "$scriptPath\Ix.NET.sln" /m /t:build /p:Configuration=$configuration
  42. Write-Host "Building Packages" -Foreground Green
  43. dotnet pack "$scriptPath\System.Interactive\System.Interactive.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  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. dotnet pack "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  52. if ($LastExitCode -ne 0) {
  53. Write-Host "Error with build" -Foreground Red
  54. if($isAppVeyor) {
  55. $host.SetShouldExit($LastExitCode)
  56. exit $LastExitCode
  57. }
  58. }
  59. dotnet pack "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  60. if ($LastExitCode -ne 0) {
  61. Write-Host "Error with build" -Foreground Red
  62. if($isAppVeyor) {
  63. $host.SetShouldExit($LastExitCode)
  64. exit $LastExitCode
  65. }
  66. }
  67. dotnet pack "$scriptPath\System.Interactive.Providers\System.Interactive.Providers.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  68. if ($LastExitCode -ne 0) {
  69. Write-Host "Error with build" -Foreground Red
  70. if($isAppVeyor) {
  71. $host.SetShouldExit($LastExitCode)
  72. exit $LastExitCode
  73. }
  74. }
  75. if($hasSignClientSecret) {
  76. Write-Host "Signing Packages" -Foreground Green
  77. $nupgks = ls $artifacts\*Interact*.nupkg | Select -ExpandProperty FullName
  78. foreach ($nupkg in $nupgks) {
  79. Write-Host "Submitting $nupkg for signing"
  80. dotnet $signClientAppPath 'sign' -c $signClientSettings -i $nupkg -s $env:SignClientSecret -n 'Ix.NET' -d 'Interactive Extensions for .NET' -u 'http://reactivex.io/'
  81. if ($LastExitCode -ne 0) {
  82. Write-Host "Error signing $nupkg" -Foreground Red
  83. if($isAppVeyor) {
  84. $host.SetShouldExit($LastExitCode)
  85. exit $LastExitCode
  86. }
  87. }
  88. Write-Host "Finished signing $nupkg"
  89. }
  90. } else {
  91. Write-Host "Client Secret not found, not signing packages"
  92. }
  93. Write-Host "Running tests" -Foreground Green
  94. $testDirectory = Join-Path $scriptPath "Tests"
  95. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  96. # Use xUnit CLI as it's significantly faster than vstest (dotnet test)
  97. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  98. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe analyse /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="$outputFile" /ReportType=DetailedXML /HideAutoProperties
  99. if ($LastExitCode -ne 0) {
  100. Write-Host "Error with tests" -Foreground Red
  101. if($isAppVeyor) {
  102. $host.SetShouldExit($LastExitCode)
  103. exit $LastExitCode
  104. }
  105. }
  106. # Either display or publish the results
  107. if ($env:CI -eq 'True')
  108. {
  109. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -p DotCover "$outputFile"
  110. }
  111. else
  112. {
  113. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  114. &"$outPutPath/index.htm"
  115. }