200_rebuild_output.ps1 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #**************************************************************************#
  2. #** QUADARAX DEPLOYMENT SCRIPTS **#
  3. #** File: 200_rebuild.ps1 **#
  4. #** Description: PowerShell script library to build current solution **#
  5. #** to output directory **#
  6. #** Version: 1.0. **#
  7. #** Updated: 26.7.2019 **#
  8. #**************************************************************************#
  9. param(
  10. # Solution file name with full path. If not defined use global solution
  11. [string] $solutionFile,
  12. # Build configuration Debug / Release. If not defined use Debug
  13. [string] $configurationName,
  14. # Defines if Clean will be called before build. If not defined use $false
  15. [bool] $cleanBeforeBuild
  16. )
  17. . ./000_bootstrap.ps1
  18. # Validate inputs
  19. if (!$solutionFile) { $solutionFile = $solutionName}
  20. if (!$configurationName) { $configurationName = $buildCfgDebug}
  21. if (!$cleanBeforeBuild) { $cleanBeforeBuild = $false}
  22. if ($configurationName -eq $buildCfgAll){
  23. Write-Host ("Configuration name {0} for this script is not allowed. Use only {1},{2}." -f $buildCfgAll, $buildCfgDebug, $buildCfgRelease) -ForegroundColor Red
  24. Break
  25. }
  26. # Script body section
  27. # May create output directory
  28. New-Item -ItemType Directory -Force -Path $projectOutputDir
  29. Write-Host "*** REBUILD - START ***" -ForegroundColor Green
  30. $slnFullPath = ("{0}\{1}" -f $projectDir, $solutionFile)
  31. Write-Host ("Solution name: {0}" -f $slnFullPath) -ForegroundColor Yellow
  32. Write-host ("Configuration: {0}" -f $configurationName) -ForegroundColor Yellow
  33. Write-host ("Output directory: {0}" -f $projectOutputDir) -ForegroundColor Yellow
  34. if ($cleanBeforeBuild -eq $true){
  35. Write-Host "Cleaning output directory" -ForegroundColor White
  36. Remove-Item -Path "$projectOutputDir\*" -Recurse
  37. }
  38. RebuildSolution -solutionFileName $slnFullPath -configurationName $configurationName -cleanBeforeBuild $cleanBeforeBuild
  39. # Gathering projects
  40. $projects = GetProjectsFromSolution $slnFullPath
  41. # Copy outputs
  42. foreach ($project in $projects) {
  43. $projectBuildOutput = "$($project.Directory)\bin\$configurationName\*"
  44. $ignoreThisProject = Test-Path -Path "$($project.Directory)\.skipoutput"
  45. if ($ignoreThisProject -eq $false){
  46. Copy-Item -Path $projectBuildOutput -Filter * -Destination $projectOutputDir -Force -Recurse
  47. Write-Host ("Files was copied from $($project.Directory) to $projectOutputDir")
  48. }
  49. }
  50. Write-Host "*** REBUILD - END ***" -ForegroundColor Green