-
Notifications
You must be signed in to change notification settings - Fork 52
/
build.ps1
60 lines (55 loc) · 2.09 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
###########################################################
# Start - Initialization - Invocation, Logging etc
###########################################################
$VerbosePreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
$scriptPath = $MyInvocation.MyCommand.Path
$scriptDir = Split-Path $scriptPath
& "$scriptDir\scripts\init.ps1"
if(-not $?)
{
throw "Initialization failure."
}
###########################################################
# End - Initialization - Invocation, Logging etc
###########################################################
$buildList=@()
$buildErrorList=@()
$projects = gci -Directory $scriptDir
Write-SpecialLog "Building Projects" (Get-ScriptName) (Get-ScriptLineNumber)
Write-SpecialLog "=================" (Get-ScriptName) (Get-ScriptLineNumber)
$projects | % {
if(Test-Path (Join-Path $_ "build.ps1"))
{
Write-SpecialLog ("Building Project: " + $_) (Get-ScriptName) (Get-ScriptLineNumber)
pushd $_
$projectName=$_.FullName
try
{
.\build.ps1
if($LASTEXITCODE -ne 0) { $buildErrorList += $projectName } else { $buildList += $projectName };
}
catch
{
$buildErrorList += $projectName
Write-ErrorLog "An exception has occurred while building: $projectName" (Get-ScriptName) (Get-ScriptLineNumber) $_
}
finally
{
popd
}
}
}
if($buildErrorList.Count -ne 0)
{
Write-ErrorLog "ERROR: One or more projects failed to build:" (Get-ScriptName) (Get-ScriptLineNumber)
$buildErrorList | % { Write-ErrorLog $_ (Get-ScriptName) (Get-ScriptLineNumber) }
Write-SpecialLog "Projects built successfully:" (Get-ScriptName) (Get-ScriptLineNumber)
$buildList | % { Write-SpecialLog $_ (Get-ScriptName) (Get-ScriptLineNumber) }
throw "Some projects failed to build, please check build output for error information."
}
else
{
Write-SpecialLog "SUCCESS: All projects built successfully!" (Get-ScriptName) (Get-ScriptLineNumber)
$buildList | % { Write-SpecialLog $_ (Get-ScriptName) (Get-ScriptLineNumber) }
}