11#Requires -Version 5
2+ #Requires -RunAsAdministrator
23[CmdletBinding(DefaultParameterSetName = 'Build')]
34param (
45 [parameter(Position = 0, ParameterSetName = 'Build')]
@@ -18,14 +19,20 @@ param (
1819function PrerequisitesLoaded {
1920 # Install required modules if missing
2021 try {
21- if ((get-module InvokeBuild -ListAvailable) -eq $null) {
22- Write-Output "Attempting to install the InvokeBuild module..."
23- $null = Install-Module InvokeBuild -Scope:CurrentUser
22+ if ((get-module PSDepend -ListAvailable) -eq $null) {
23+ Write-Host "Attempting to install the PSDepend module..."
24+ $null = Install-Module PSDepend -Scope:CurrentUser
2425 }
25- if (get-module InvokeBuild -ListAvailable) {
26- Write-Output -NoNewLine "Importing InvokeBuild module"
27- Import-Module InvokeBuild -Force
28- Write-Output '...Loaded!'
26+ if (get-module PSDepend -ListAvailable) {
27+ Write-Host -NoNewLine "Importing PSDepend module"
28+ Import-Module PSDepend -Force
29+ Write-Host '...Loaded!'
30+
31+ Write-Host -NoNewLine 'Installing dependencies...'
32+ Invoke-PSDepend -Path $(Join-Path $(Get-Location) 'Requirements.psd1') -Test
33+ Invoke-PSDepend -Path $(Join-Path $(Get-Location) 'Requirements.psd1') -Force
34+ Invoke-PSDepend -Path $(Join-Path $(Get-Location) 'Requirements.psd1') -Import -Force
35+ Write-Host 'Installed!'
2936 return $true
3037 }
3138 else {
@@ -39,8 +46,8 @@ function PrerequisitesLoaded {
3946
4047function CleanUp {
4148 try {
42- Write-Output ''
43- Write-Output 'Attempting to clean up the session (loaded modules and such)...'
49+ Write-Host ''
50+ Write-Host 'Attempting to clean up the session (loaded modules and such)...'
4451 Invoke-Build -Task BuildSessionCleanup
4552 Remove-Module InvokeBuild
4653 }
@@ -77,8 +84,8 @@ switch ($psCmdlet.ParameterSetName) {
7784 Invoke-Build
7885 }
7986 catch {
80- Write-Output 'Build Failed with the following error:'
81- Write-Output $_
87+ Write-Host 'Build Failed with the following error:'
88+ Write-Host $_
8289 }
8390 }
8491
@@ -88,8 +95,8 @@ switch ($psCmdlet.ParameterSetName) {
8895 Invoke-Build -Task InstallAndTestModule
8996 }
9097 catch {
91- Write-Output 'Install and test of module failed:'
92- Write-Output $_
98+ Write-Host 'Install and test of module failed:'
99+ Write-Host $_
93100 }
94101 }
95102
0 commit comments