-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
52 lines (43 loc) · 1.97 KB
/
build.ps1
File metadata and controls
52 lines (43 loc) · 1.97 KB
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
#### By Chris Stone <chris.stone@nuwavepartners.com> v0.0.30 2020-06-12T13:06:21.016Z
# Based on https://github.com/RamblingCookieMonster/PSDeploy
function Resolve-Module {
[Cmdletbinding()]
Param (
[Parameter(Mandatory)]
[string[]] $Name
)
Process {
Foreach ($ModuleName in $Name) {
Write-Output "Resolving Module $($ModuleName)"
$Module = Get-Module -Name $ModuleName -ListAvailable
If ($Module) {
$Version = $Module | Measure-Object -Property Version -Maximum | Select-Object -ExpandProperty Maximum
$GalleryVersion = Find-Module -Name $ModuleName -Repository PSGallery | Measure-Object -Property Version -Maximum | Select-Object -ExpandProperty Maximum
If ($Version -lt $GalleryVersion) {
Write-Output "`tOutdated, Version [$($Version.tostring())] is installed. Updating to Gallery Version [$($GalleryVersion.tostring())]"
Install-Module -Name $ModuleName -Force
Import-Module -Name $ModuleName -Force -RequiredVersion $GalleryVersion
} else {
Write-Output "`tInstalled, Importing $($ModuleName)"
Import-Module -Name $ModuleName -Force -RequiredVersion $Version
}
} else {
Write-Output "`tMissing, installing Module"
Install-Module -Name $ModuleName -Force
Import-Module -Name $ModuleName -Force -RequiredVersion $Version
}
}
}
}
Write-Output ("`n{0} started " -f $MyInvocation.MyCommand.Name ).PadRight(70,'-')
# Grab nuget bits, PSGallery, install modules
Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null
If ((Get-PSRepository -Name PSGallery).InstallationPolicy -ne 'Trusted') { Set-PSRepository -Name PSGallery -InstallationPolicy Trusted }
Resolve-Module -Name Psake, PSDeploy, Pester, BuildHelpers
# From BuildHelpers
Set-BuildEnvironment -Force
# Go for a deployment in CI system
If ($env:BHBuildSystem -ne 'Unknown') { $BuildOpts = @{ taskList = 'Deploy' } }
# Everything else should be in PSAke
Invoke-psake -buildFile "$env:BHProjectPath\psake.ps1" @BuildOpts
Exit ( [int]( -not $psake.build_success ) )