build-new.ps1 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
  2. $configuration = "Release"
  3. $isCloudBuild = Test-Path -Path env:\TF_BUILD
  4. $outputLocation = Join-Path $scriptPath "testResults"
  5. $rootPath = (Resolve-Path .).Path
  6. $artifacts = Join-Path $rootPath "artifacts"
  7. $signClientSettings = Join-Path (Join-Path (Get-Item $scriptPath).Parent.Parent.FullName "scripts") "SignClientSettings.json"
  8. $hasSignClientSecret = !([string]::IsNullOrEmpty($env:SignClientSecret))
  9. $signClientAppPath = ".\packages\SignClient\tools\netcoreapp2.0\SignClient.dll"
  10. #remove any old coverage file
  11. md -Force $outputLocation | Out-Null
  12. $outputPath = (Resolve-Path $outputLocation).Path
  13. $outputFileDotCover1 = Join-Path $outputPath -childpath 'coverage-ix1.dcvr'
  14. $outputFileDotCover2 = Join-Path $outputPath -childpath 'coverage-ix2.dcvr'
  15. $outputFileDotCover = Join-Path $outputPath -childpath 'coverage-ix.dcvr'
  16. $outputFile = Join-Path $outputPath -childpath 'coverage-ix.xml'
  17. Remove-Item $outputPath -Force -Recurse
  18. md -Force $outputLocation | Out-Null
  19. if (!(Test-Path .\nuget.exe)) {
  20. wget "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -outfile .\nuget.exe
  21. }
  22. # get tools
  23. .\nuget.exe install -excludeversion SignClient -Version 0.9.0 -outputdirectory packages
  24. .\nuget.exe install -excludeversion JetBrains.dotCover.CommandLineTools -pre -outputdirectory packages
  25. .\nuget.exe install -excludeversion Nerdbank.GitVersioning -Version 2.1.23 -outputdirectory packages
  26. .\nuget.exe install -excludeversion ReportGenerator -outputdirectory packages
  27. #.\nuget.exe install -excludeversion coveralls.io -outputdirectory packages
  28. .\nuget.exe install -excludeversion coveralls.io.dotcover -outputdirectory packages
  29. #update version
  30. $versionObj = .\packages\Nerdbank.GitVersioning\tools\get-version.ps1
  31. $packageSemVer = $versionObj.NuGetPackageVersion
  32. Write-Host "Building $packageSemVer" -Foreground Green
  33. New-Item -ItemType Directory -Force -Path $artifacts
  34. Write-Host "Building $scriptPath\Ix.NET.sln" -Foreground Green
  35. # Using MSBuild here since th UWP test project cannot be built by the dotnet CLI
  36. #msbuild "$scriptPath\Ix.NET.sln" /m /t:build /p:Configuration=$configuration
  37. Write-Host "Building Packages" -Foreground Green
  38. dotnet pack "$scriptPath\System.Interactive\System.Interactive.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  39. if ($LastExitCode -ne 0) {
  40. Write-Host "Error with build" -Foreground Red
  41. if($isCloudBuild) {
  42. $host.SetShouldExit($LastExitCode)
  43. exit $LastExitCode
  44. }
  45. }
  46. dotnet pack "$scriptPath\System.Interactive.Async\System.Interactive.Async.csproj" -c $configuration /p:PackageOutputPath=$artifacts /p:NoPackageAnalysis=true
  47. if ($LastExitCode -ne 0) {
  48. Write-Host "Error with build" -Foreground Red
  49. if($isCloudBuild) {
  50. $host.SetShouldExit($LastExitCode)
  51. exit $LastExitCode
  52. }
  53. }
  54. dotnet pack "$scriptPath\System.Interactive.Async.Providers\System.Interactive.Async.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($isCloudBuild) {
  58. $host.SetShouldExit($LastExitCode)
  59. exit $LastExitCode
  60. }
  61. }
  62. dotnet pack "$scriptPath\System.Interactive.Providers\System.Interactive.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($isCloudBuild) {
  66. $host.SetShouldExit($LastExitCode)
  67. exit $LastExitCode
  68. }
  69. }
  70. if($hasSignClientSecret) {
  71. Write-Host "Signing Packages" -Foreground Green
  72. $nupgks = ls $artifacts\*Interact*.nupkg | Select -ExpandProperty FullName
  73. foreach ($nupkg in $nupgks) {
  74. Write-Host "Submitting $nupkg for signing"
  75. 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/'
  76. if ($LastExitCode -ne 0) {
  77. Write-Host "Error signing $nupkg" -Foreground Red
  78. if($isCloudBuild) {
  79. $host.SetShouldExit($LastExitCode)
  80. exit $LastExitCode
  81. }
  82. }
  83. Write-Host "Finished signing $nupkg"
  84. }
  85. } else {
  86. Write-Host "Client Secret not found, not signing packages"
  87. }
  88. Write-Host "Running tests" -Foreground Green
  89. $testDirectory = Join-Path $scriptPath "System.Interactive.Tests"
  90. # OpenCover isn't working currently. So run tests on CI and coverage with JetBrains
  91. $dotnet = "$env:ProgramFiles\dotnet\dotnet.exe"
  92. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --filter `"SkipCI!=true`"" /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"
  93. if ($LastExitCode -ne 0) {
  94. Write-Host "Error with tests" -Foreground Red
  95. if($isCloudBuild) {
  96. $host.SetShouldExit($LastExitCode)
  97. exit $LastExitCode
  98. }
  99. }
  100. $testDirectory = Join-Path $scriptPath "System.Interactive.Async.Tests"
  101. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe cover /targetexecutable="$dotnet" /targetworkingdir="$testDirectory" /targetarguments="test -c $configuration --filter `"SkipCI!=true`"" /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"
  102. if ($LastExitCode -ne 0) {
  103. Write-Host "Error with tests" -Foreground Red
  104. if($isCloudBuild) {
  105. $host.SetShouldExit($LastExitCode)
  106. exit $LastExitCode
  107. }
  108. }
  109. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe merge /Source="$outputFileDotCover1;$outputFileDotCover2" /Output="$outputFileDotCover"
  110. .\packages\JetBrains.dotCover.CommandLineTools\tools\dotCover.exe report /Source="$outputFileDotCover" /Output="$outputFile" /ReportType=DetailedXML /HideAutoProperties
  111. # Either display or publish the results
  112. if ($isCloudBuild -eq 'True')
  113. {
  114. .\packages\coveralls.io.dotcover\tools\coveralls.net.exe -p DotCover "$outputFile"
  115. }
  116. else
  117. {
  118. .\packages\ReportGenerator\tools\ReportGenerator.exe -reports:"$outputFile" -targetdir:"$outputPath"
  119. &"$outPutPath/index.htm"
  120. }