Terminal.Gui.PowerShell.Analyzers.psm1 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <#
  2. .SYNOPSIS
  3. Builds all analyzer projects in Debug and Release configurations.
  4. .DESCRIPTION
  5. Uses dotnet build to build all analyzer projects, with optional behavior changes via switch parameters.
  6. .PARAMETER AutoClose
  7. Automatically close running Visual Studio processes which have the Terminal.sln solution loaded, before taking any other actions.
  8. .PARAMETER AutoLaunch
  9. Automatically start a new Visual Studio process and load the solution after completion.
  10. .PARAMETER Force
  11. Carry out operations unconditionally and do not prompt for confirmation.
  12. .PARAMETER NoClean
  13. Do not delete the bin and obj folders before building the analyzers. Usually best not to use this, but can speed up the builds slightly.
  14. .PARAMETER Quiet
  15. Write less text output to the terminal.
  16. .INPUTS
  17. None
  18. .OUTPUTS
  19. None
  20. #>
  21. Function Build-Analyzers {
  22. [CmdletBinding()]
  23. param(
  24. [Parameter(Mandatory=$false, HelpMessage="Automatically close running Visual Studio processes which have the Terminal.sln solution loaded, before taking any other actions.")]
  25. [switch]$AutoClose,
  26. [Parameter(Mandatory=$false, HelpMessage="Automatically start a new Visual Studio process and load the solution after completion.")]
  27. [switch]$AutoLaunch,
  28. [Parameter(Mandatory=$false, HelpMessage="Carry out operations unconditionally and do not prompt for confirmation.")]
  29. [switch]$Force,
  30. [Parameter(Mandatory=$false, HelpMessage="Do not delete the bin and obj folders before building the analyzers.")]
  31. [switch]$NoClean,
  32. [Parameter(Mandatory=$false, HelpMessage="Write less text output to the terminal.")]
  33. [switch]$Quiet
  34. )
  35. if($AutoClose) {
  36. if(!$Quiet) {
  37. Write-Host Closing Visual Studio processes
  38. }
  39. Close-Solution
  40. }
  41. if($Force){
  42. $response = 'Y'
  43. }
  44. elseif(!$Force && $NoClean){
  45. $response = ($r = Read-Host "Pre-build Terminal.Gui.InternalAnalyzers without removing old build artifacts? [Y/n]") ? $r : 'Y'
  46. }
  47. else{
  48. $response = ($r = Read-Host "Delete bin and obj folders for Terminal.Gui and Terminal.Gui.InternalAnalyzers and pre-build Terminal.Gui.InternalAnalyzers? [Y/n]") ? $r : 'Y'
  49. }
  50. if (($response -ne 'Y')) {
  51. Write-Host Took no action
  52. return
  53. }
  54. Push-Location $InternalAnalyzersProjectDirectory
  55. if(!$NoClean) {
  56. if(!$Quiet) {
  57. Write-Host Deleting bin and obj folders for Terminal.Gui
  58. }
  59. Remove-Item -Recurse -Force $TerminalGuiProjectDirectory/bin -ErrorAction SilentlyContinue
  60. Remove-Item -Recurse -Force $TerminalGuiProjectDirectory/obj -ErrorAction SilentlyContinue
  61. if(!$Quiet) {
  62. Write-Host Deleting bin and obj folders for Terminal.Gui.InternalAnalyzers
  63. }
  64. Remove-Item -Recurse -Force $InternalAnalyzersProjectDirectory/bin -ErrorAction SilentlyContinue
  65. Remove-Item -Recurse -Force $InternalAnalyzersProjectDirectory/obj -ErrorAction SilentlyContinue
  66. }
  67. if(!$Quiet) {
  68. Write-Host Building analyzers in Debug configuration
  69. }
  70. dotnet build $InternalAnalyzersProjectFilePath --no-incremental --nologo --force --configuration Debug
  71. if(!$Quiet) {
  72. Write-Host Building analyzers in Release configuration
  73. }
  74. dotnet build $InternalAnalyzersProjectFilePath --no-incremental --nologo --force --configuration Release
  75. Pop-Location
  76. if(!$AutoLaunch) {
  77. Write-Host -ForegroundColor Green Finished. Restart Visual Studio for changes to take effect.
  78. } else {
  79. if(!$Quiet) {
  80. Write-Host -ForegroundColor Green Finished. Re-loading Terminal.sln.
  81. }
  82. Open-Solution
  83. }
  84. return
  85. }