Skip to content

Commit d2c1c91

Browse files
committed
PSDepend for build.ps1
1 parent d011f7a commit d2c1c91

6 files changed

Lines changed: 54 additions & 20 deletions

File tree

Build.ps1

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ param (
1818
function PrerequisitesLoaded {
1919
# Install required modules if missing
2020
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
21+
if ((get-module PSDepend -ListAvailable) -eq $null) {
22+
Write-Host "Attempting to install the PSDepend module..."
23+
$null = Install-Module PSDepend -Scope:CurrentUser
2424
}
25-
if (get-module InvokeBuild -ListAvailable) {
26-
Write-Output -NoNewLine "Importing InvokeBuild module"
27-
Import-Module InvokeBuild -Force
28-
Write-Output '...Loaded!'
25+
if (get-module PSDepend -ListAvailable) {
26+
Write-Host -NoNewLine "Importing PSDepend module"
27+
Import-Module PSDepend -Force
28+
Write-Host '...Loaded!'
29+
30+
Write-Host -NoNewLine 'Installing dependencies...'
31+
Invoke-PSDepend -Path $(Join-Path $(Get-Location) 'Requirements.psd1') -Test
32+
Invoke-PSDepend -Path $(Join-Path $(Get-Location) 'Requirements.psd1') -Force
33+
Invoke-PSDepend -Path $(Join-Path $(Get-Location) 'Requirements.psd1') -Import -Force
34+
Write-Host 'Installed!'
2935
return $true
3036
}
3137
else {

Requirements.psd1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@{
2+
InvokeBuild = @{
3+
version = 'latest'
4+
source = 'PSGalleryModule'
5+
}
6+
}

build/PSDepend/build.depend.psd1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@
1919
version = '0.2.26'
2020
source = 'PSGalleryModule'
2121
}
22+
ModuleBuildToolsTemp = @{
23+
version = '0.0.1'
24+
source = 'PSGalleryModule'
25+
}
2226
}

plaster/ModuleBuild/scaffold/Build.template

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#Requires -Version 5
2+
#Requires -RunAsAdministrator
23
[CmdletBinding(DefaultParameterSetName = 'Build')]
34
param (
45
[parameter(Position = 0, ParameterSetName = 'Build')]
@@ -18,14 +19,20 @@ param (
1819
function 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

4047
function 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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@{
2+
InvokeBuild = @{
3+
version = 'latest'
4+
source = 'PSGalleryModule'
5+
}
6+
}

plaster/PlasterContent.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,5 +236,10 @@ $Content = @(
236236
Source = 'scaffold\appveyor.yml'
237237
Destination = 'appveyor.yml'
238238
Condition = '$PLASTER_PARAM_CICD -eq "appveyor"'
239+
},
240+
@{
241+
ContentType = 'file'
242+
Source = 'scaffold\Requirements.psd1'
243+
Destination = 'Requirements.psd1'
239244
}
240245
)

0 commit comments

Comments
 (0)