forked from Dejulia489/ZabbixPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
41 lines (40 loc) · 1.33 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
[CmdletBinding()]
param
(
[Parameter()]
[string]
$Task = 'Default',
[Parameter()]
[string]
$moduleInstallScope = 'CurrentUser'
)
Write-Host "[$($MyInvocation.MyCommand.Name)]: Starting build..."
Write-Host "[$($MyInvocation.MyCommand.Name)]: Checking module dependencies..."
$modules = @(
@{
Name = 'InvokeBuild'
Repository = 'PSGallery'
Version = '5.4.1'
}
@{
Name = 'Pester'
Repository = 'PSGallery'
Version = '4.4.0'
}
)
Foreach ($module in $modules)
{
Try
{
$installedModule = Get-InstalledModule -Name $module.Name -RequiredVersion $module.Version -ErrorAction 'Stop'
Write-Host "[$($MyInvocation.MyCommand.Name)]: Located the installed module: [$($installedModule.Name)] - [$($installedModule.Version)]"
}
Catch
{
Write-Host "[$($MyInvocation.MyCommand.Name)]: Installing: [$($module.Name)] - [$($module.Version)] from [$($module.Repository)]"
Install-Module -Name $module.Name -RequiredVersion $module.Version -Repository $module.Repository -Force -AllowClobber -Scope $moduleInstallScope -SkipPublisherCheck
}
Import-Module -Name $module.Name -RequiredVersion "$($module.Version)" -Force
}
Write-Host "[$($MyInvocation.MyCommand.Name)]: Invoking build..."
Invoke-Build $Task -Result 'Result'