-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
build.ps1
63 lines (50 loc) · 2.38 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
61
62
63
[cmdletbinding()]
param(
[string[]]$Task = 'default',
[switch]$Help,
[switch]$UpdateModules
)
function Resolve-Module {
[Cmdletbinding()]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[string[]]$Name,
[switch]$Update
)
Process {
foreach ($moduleName in $Name) {
$module = Get-Module -Name $moduleName -ListAvailable -Verbose:$false
Write-Verbose -Message "Resolving [$($ModuleName)]"
if ($module) {
if ($PSBoundParameters.ContainsKey('UpdateModules')) {
$version = $module | Measure-Object -Property Version -Maximum | Select-Object -ExpandProperty Maximum
$galleryVersion = Find-Module -Name $moduleName -Repository PSGallery -Verbose:$false |
Measure-Object -Property Version -Maximum |
Select-Object -ExpandProperty Maximum
if ($version -lt $galleryVersion) {
Write-Verbose -Message "$($moduleName) Installed Version [$($Version.tostring())] is outdated. Installing Gallery Version [$($galleryVersion.tostring())]"
Install-Module -Name $moduleName -Repository PSGallery -Verbose:$false -Force
Import-Module -Name $moduleName -Verbose:$false -Force -RequiredVersion $galleryVersion
}
}
Write-Verbose -Message "Importing [$($moduleName)]"
Import-Module -Name $moduleName -Verbose:$false -Force
}
else {
Write-Verbose -Message "[$($moduleName)] Missing, installing Module"
Install-Module -Name $moduleName -Repository PSGallery -Verbose:$false -Force
Import-Module -Name $moduleName -Verbose:$false -Force -RequiredVersion $version
}
}
}
}
Get-PackageProvider -Name Nuget -ForceBootstrap | Out-Null
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
'BuildHelpers', 'psake', 'Pester', 'PSDeploy', 'PSScriptAnalyzer' | Resolve-Module -Update:$UpdateModules
if ($PSBoundParameters.ContainsKey('Help')) {
Get-PSakeScriptTasks -buildFile "$PSScriptRoot\psake.ps1"
return
}
Set-BuildEnvironment -Force
Invoke-psake -buildFile "$PSScriptRoot\psake.ps1" -taskList $Task -nologo -Verbose:$VerbosePreference
exit ( [int]( -not $psake.build_success ) )