-
Notifications
You must be signed in to change notification settings - Fork 36
/
Build-MicroServices.ps1
64 lines (48 loc) · 2.21 KB
/
Build-MicroServices.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
61
62
63
64
[CmdletBinding()]
param ()
Import-Module -Name "$PSScriptRoot\Invoke-MsBuild.psm1"
Import-Module -Name "$PSScriptRoot\Invoke-NuGetPackageRestore.psm1"
$solutions = @(
@{ Solution = "Microservices Common"; Path = "$PSScriptRoot\MicroService-Common\MicroServices.Common.sln" },
@{ Solution = "Admin"; Path = "$PSScriptRoot\Admin\Admin.sln" },
@{ Solution = "Cashier"; Path = "$PSScriptRoot\Cashier\Cashier.sln" },
@{ Solution = "Barista"; Path = "$PSScriptRoot\Barista\Barista.sln" }
)
Function ReportProgress($currentSolution, $currentStatus, $currentPercentage) {
Write-Progress -Id 1 -Activity "Microservices Build" -Status "Building $currentSolution" -CurrentOperation $currentStatus -PercentComplete $currentPercentage
}
Function BuildSolution($pathToSolution, $solutionName, $alreadyComplete, $totalSteps) {
$currentProgress = $alreadyComplete / $totalSteps * 100
$progressStep = 1 / $totalSteps * 100 / 2
ReportProgress $solutionName "Restoring NuGet packages" $currentProgress
$nugetSucceeded = Invoke-NuGetPackageRestore -Path $pathToSolution
if (!$nugetSucceeded)
{
return $nugetSucceeded
}
ReportProgress $solutionName "Running MSBuild" ($currentProgress + $progressStep)
$buildSucceeded = Invoke-MsBuild -Path $pathToSolution
return $buildSucceeded;
}
[System.Collections.ArrayList]$results = @()
Function AddResult($solution, $result) {
$object = New-Object -TypeName PSObject
$object | Add-Member -MemberType NoteProperty -Name "Result" -Value $result
$object | Add-Member -MemberType NoteProperty -Name "Solution" -Value $solution.Solution
$object | Add-Member -MemberType NoteProperty -Name "Location" -Value $solution.Path
$results.Add($object) | Out-Null
}
foreach ($solution in $solutions) {
if (($results | Where-Object { $_.Result -eq "Failed" }) -ne $null) {
AddResult $solution "Skipped"
continue
}
$success = BuildSolution $solution.Path $solution.Solution $solutions.IndexOf($solution) $solutions.Length
if ($success) {
AddResult $solution "Succeeded"
}
else {
AddResult $solution "Failed"
}
}
return $results