#**************************************************************************#
#**  QUADARAX DEPLOYMENT SCRIPTS                                         **#
#**  File: 100_rebuild.ps1                                               **#
#**  Description: PowerShell script library to build current solution    **#
#**  Version: 1.0.                                                       **#
#**  Updated: 26.7.2019                                                  **# 
#**************************************************************************#
param(
        # Solution file name with full path. If not defined use global solution
        [string] $solutionFile,
        # Build configuration Debug / Release / All. If not defined use Debug
        [string] $configurationName,
        # Defines if Clean will be called before build. If not defined use $false
        [bool] $cleanBeforeBuild
)
. ./000_bootstrap.ps1

# Validate inputs
if (!$solutionFile) { $solutionFile = $solutionName}
if (!$configurationName) { $configurationName = $buildCfgDebug}
if (!$cleanBeforeBuild) { $cleanBeforeBuild = $false}

# Script body section
Write-Host "*** REBUILD - START ***" -ForegroundColor Green
$slnFullPath = ("{0}\{1}" -f $projectDir, $solutionFile)
Write-Host ("Solution name: {0}" -f $slnFullPath) -ForegroundColor Yellow
Write-host ("Configuration: {0}" -f $configurationName) -ForegroundColor Yellow
if ($configurationName -eq $buildCfgAll){
        RebuildSolution -solutionFileName $slnFullPath -configurationName $buildCfgDebug -cleanBeforeBuild $cleanBeforeBuild
        RebuildSolution -solutionFileName $slnFullPath -configurationName $buildCfgRelease -cleanBeforeBuild $cleanBeforeBuild
}
else {
        RebuildSolution -solutionFileName $slnFullPath -configurationName $configurationName -cleanBeforeBuild $cleanBeforeBuild
}
Write-Host "*** REBUILD - END ***" -ForegroundColor Green