Skip to content

Commit cf23cc4

Browse files
committed
Use PSDepend for build module dependencies.
1 parent cbc6b04 commit cf23cc4

25 files changed

Lines changed: 149 additions & 83 deletions

buildreports/CodeHealthReport-Private.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ <h1>
189189
<div class="col-sm-4 col-md-5 col-lg-4 right-header">
190190
<h5>
191191
Analyzed path :<span class="right-header-data"> src\private</span><br>
192-
Analysis date :<span class="right-header-data"> 2019-12-17 12:45:47Z</span>
192+
Analysis date :<span class="right-header-data"> 2019-12-17 15:03:40Z</span>
193193
</h5>
194194
</div>
195195
</div>

buildreports/CodeHealthReport-Public.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ <h1>
189189
<div class="col-sm-4 col-md-5 col-lg-4 right-header">
190190
<h5>
191191
Analyzed path :<span class="right-header-data"> src\public</span><br>
192-
Analysis date :<span class="right-header-data"> 2019-12-17 12:44:38Z</span>
192+
Analysis date :<span class="right-header-data"> 2019-12-17 15:01:55Z</span>
193193
</h5>
194194
</div>
195195
</div>

plaster/ModuleBuild/plasterManifest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
templateType="Project" xmlns="http://www.microsoft.com/schemas/PowerShell/Plaster/v1">
55
<metadata>
66
<name>ModuleBuild</name>
7-
<id>44af0521-ca39-46ad-95a4-cd8e2f644434</id>
7+
<id>5f0f699c-8cbb-4522-b2a9-d9cebf507c39</id>
88
<version>0.0.1</version>
99
<title>New ModuleBuild Project</title>
1010
<description>Create a new PowerShell Module with a ModuleBuild wrapper</description>
@@ -253,6 +253,9 @@
253253
<file
254254
source="scaffold\build\dotsource\*"
255255
destination="build\dotsource" />
256+
<file
257+
source="scaffold\build\PSDepend\*"
258+
destination="build\PSDepend" />
256259
<file
257260
source="scaffold\build\tools\*"
258261
destination="build\tools" />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# PSDepend
2+
3+
PSDepend will use this folder to install build dependencies
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@{
2+
PSDependOptions = @{
3+
Target = '$DependencyFolder'
4+
AddToPath = $True
5+
}
6+
PSScriptAnalyzer = @{
7+
version = '1.18.3'
8+
source = 'PSGalleryModule'
9+
}
10+
PlatyPS = @{
11+
version = '0.14.0'
12+
source = 'PSGalleryModule'
13+
}
14+
'Powershell-YAML' = @{
15+
version = '0.4.1'
16+
source = 'PSGalleryModule'
17+
}
18+
PSCodeHealth = @{
19+
version = '0.2.26'
20+
source = 'PSGalleryModule'
21+
}
22+
}

plaster/ModuleBuild/scaffold/gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# ignore any temp directory (used in build steps)
22
temp/
33

4+
# Ignore PSDepend installed build modules dependencies.
5+
build/PSDepend/*
6+
!build/PSDepend/README.md
7+
!build/PSDepend/build.depend.psd1
8+
49
# PSGallery publishing file can contain personal API key and paths and thus we want to ignore it if it exists
510
.psgallery
611

plaster/ModuleBuild/scaffold/modulename.build.template

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,38 +51,22 @@ task ValidateRequirements {
5151
assert ($PSVersionTable.PSVersion.Major.ToString() -eq '5') 'Powershell 5 is required for this build to function properly (you can comment this assert out if you are able to work around this requirement)'
5252
}
5353

54-
#Synopsis: Load required modules if available. Otherwise try to install, then load it.
54+
#Synopsis: Load required build modules using PSDepend
5555
task LoadRequiredModules {
5656
Write-Description White 'Loading all required modules for the build framework' -accent
5757

58-
# These are required for a full build process and will be automatically installed if they aren't available
59-
$Script:RequiredModules = @('PlatyPS')
60-
61-
# Some optional modules
62-
if ($Script:BuildEnv.OptionAnalyzeCode) {
63-
$Script:RequiredModules += 'PSScriptAnalyzer'
64-
}
65-
if ($Script:BuildEnv.OptionGenerateReadTheDocs) {
66-
$Script:RequiredModules += 'Powershell-YAML'
67-
}
68-
if ($Script:BuildEnv.OptionCodeHealthReport) {
69-
$Script:RequiredModules += 'PSCodeHealth'
70-
}
71-
$Script:RequiredModules | Foreach-Object {
72-
if ((get-module $_ -ListAvailable) -eq $null) {
73-
Write-Description White "Installing $($_) Module" -Level 2
74-
$null = Install-Module $_ -Scope:CurrentUser
75-
}
76-
if (get-module $_ -ListAvailable) {
77-
Write-Description White "Importing $($_) Module" -Level 2
78-
Import-Module $_ -Force
79-
}
80-
else {
81-
throw 'How did you even get here?'
82-
}
58+
if ((Get-Module PSDepend -ListAvailable) -eq $null) {
59+
Write-Description White "Installing PSDepend Module" -Level 2
60+
$null = Install-Module PSDepend -Scope:CurrentUser
8361
}
62+
63+
$PSDependFolder = $(Join-Path $Script:BuildEnv.BuildToolFolder 'PSDepend')
64+
$PSDependBuildFile = $(Join-Path $PSDependFolder 'build.depend.psd1')
65+
Invoke-PSDepend -Path $PSDependBuildFile -Force
66+
Invoke-PSDepend -Path $PSDependBuildFile -Import -Force
8467
}
8568

69+
8670
#Synopsis: Load dot sourced functions into this build session
8771
task LoadBuildTools {
8872
Write-Description White 'Sourcing all of the required build functions' -accent

plaster/PlasterContent.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ $Content = @(
137137
Source = 'scaffold\build\dotsource\*'
138138
Destination = 'build\dotsource'
139139
},
140+
@{
141+
ContentType = 'file'
142+
Source = 'scaffold\build\PSDepend\*'
143+
Destination = 'build\PSDepend'
144+
},
140145
@{
141146
ContentType = 'file'
142147
Source = 'scaffold\build\tools\*'

0 commit comments

Comments
 (0)