Skip to content

Commit 12b8f75

Browse files
committed
Refactored psake build script.
This separates out the user customizations into a separate file build.settings.ps1. Also made changes related to the discussion in issue #145. Fixed some bugs with the build script as well after a fair bit of testing. Too bad my code-signing cert expired last month. Hopefully DigiCert will come through with a new cert so I can test the Sign task.
1 parent af75068 commit 12b8f75

File tree

9 files changed

+430
-343
lines changed

9 files changed

+430
-343
lines changed

.vscode/tasks.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@
6666
]
6767
},
6868
{
69-
"taskName": "Build Docs",
69+
"taskName": "BuildHelp",
7070
"suppressTaskName": true,
7171
"showOutput": "always",
7272
"args": [
73-
"Write-Host 'Invoking psake...'; Invoke-psake build.psake.ps1 -taskList BuildDocs;",
74-
"Invoke-Command { Write-Host 'Completed BuildDocs task in task runner.' }"
73+
"Write-Host 'Invoking psake...'; Invoke-psake build.psake.ps1 -taskList BuildHelp;",
74+
"Invoke-Command { Write-Host 'Completed BuildHelp task in task runner.' }"
7575
]
7676
},
7777
{

build.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# This builds this module by invoking the build.psake.ps1 script
1+
#Requires -Modules psake
22

3-
if ($null -eq (Get-Module -Name PSake -ListAvailable)) {
4-
throw "You need to install PSake before continuing. Install with 'Install-Module PSake -Scope CurrentUser'."
5-
}
6-
7-
Import-Module Psake
3+
# Builds the module by invoking psake on the build.psake.ps1 script.
84
Invoke-PSake $PSScriptRoot\build.psake.ps1 -taskList Build

build.psake.ps1

Lines changed: 73 additions & 163 deletions
Large diffs are not rendered by default.

build.settings.ps1

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
###############################################################################
2+
# Customize these properties and tasks for your module.
3+
###############################################################################
4+
5+
Properties {
6+
# ----------------------- Basic properties --------------------------------
7+
8+
# The root directories for the module's docs, src and test.
9+
$DocsRootDir = "$PSScriptRoot/docs"
10+
$SrcRootDir = "$PSScriptRoot/src"
11+
$TestRootDir = "$PSScriptRoot/test"
12+
13+
# The name of your module should match the basename of the PSD1 file.
14+
$ModuleName = Get-Item $SrcRootDir/*.psd1 |
15+
Where-Object { $null -ne (Test-ModuleManifest -Path $_ -ErrorAction SilentlyContinue) } |
16+
Select-Object -First 1 | Foreach-Object BaseName
17+
18+
# The $OutDir must match the ModuleName in order to support publishing the module.
19+
$ReleaseDir = "$PSScriptRoot/Release"
20+
$OutDir = "$ReleaseDir/$ModuleName"
21+
22+
# Default Locale used for documentation generatioon, defaults to en-US.
23+
$DefaultLocale = $null
24+
25+
# Items in the $Exclude array will not be copied to the $OutDir e.g. $Exclude = @('.gitattributes')
26+
# Typically you wouldn't put any file under the src dir unless the file was going to ship with
27+
# the module. However, if there are such files, add their $SrcRootDir relative paths to the exclude list.
28+
$Exclude = @()
29+
30+
31+
# ------------------- Script signing properties ---------------------------
32+
33+
# Set to $true if you want to sign your scripts. You will need to have a code-signing certificate.
34+
# You can specify the certificate's subject name below. If not specified, you will be prompted to
35+
# provide either a subject name or path to a PFX file. After this one time prompt, the value will
36+
# saved for future use and you will no longer be prompted.
37+
$SignScripts = $false
38+
39+
# Specify the Subject Name of the certificate used to sign your scripts. Leave it as $null and the
40+
# first time you build, you will be prompted to enter your code-signing certificate's Subject Name.
41+
# This variable is used only if $SignScripts is set to $true.
42+
#
43+
# This does require the code-signing certificate to be installed to your certificate store. If you
44+
# have a code-signing certificate in a PFX file, install the certificate to your certificate store
45+
# with the command below. You may be prompted for the certificate's password.
46+
#
47+
# Import-PfxCertificate -FilePath .\myCodeSigingCert.pfx -CertStoreLocation Cert:\CurrentUser\My
48+
#
49+
$CertSubjectName = $null
50+
51+
52+
# -------------------- Publishing properties ------------------------------
53+
54+
# Your NuGet API key for the PSGallery. Leave it as $null and the first time you publish,
55+
# you will be prompted to enter your API key. The build will store the key encrypted in the
56+
# settings file, so that on subsequent publishes you will no longer be prompted for the API key.
57+
$NuGetApiKey = $null
58+
59+
# Name of the repository you wish to publish to. If $null is specified the default repo (PowerShellGallery) is used.
60+
$PublishRepository = $null
61+
62+
# Path to the release notes file. Set to $null if the release notes reside in the manifest file.
63+
# The contents of this file are used during publishing for the ReleaseNotes parameter.
64+
$ReleaseNotesPath = "$PSScriptRoot/ReleaseNotes.md"
65+
66+
67+
# ----------------------- Misc properties ---------------------------------
68+
69+
# In addition, PFX certificates are supported in an interactive scenario only,
70+
# as a way to import a certificate into the user personal store for later use.
71+
# This can be provided using the CertPfxPath parameter. PFX passwords will not be stored.
72+
$SettingsPath = "$env:LOCALAPPDATA\Plaster\NewModuleTemplate\SecuredBuildSettings.clixml"
73+
74+
# The local installation directory for the install task. Defaults to your user PSModulePath.
75+
$InstallPath = $null
76+
77+
# Specifies an output file path to send to Invoke-Pester's -OutputFile parameter.
78+
# This is typically used to write out test results so that they can be sent to a CI
79+
# system like AppVeyor.
80+
$TestOutputFile = $null
81+
82+
# Specifies the test output format to use when the TestOutputFile property is given
83+
# a path. This parameter is passed through to Invoke-Pester's -OutputFormat parameter.
84+
$TestOutputFormat = "NUnitXml"
85+
}
86+
87+
###############################################################################
88+
# Customize these tasks for performing operations before and/or after Build.
89+
###############################################################################
90+
91+
# Executes before the BuildImpl phase of the Build task.
92+
Task PreBuild {
93+
}
94+
95+
# Executes after the Sign phase of the Build task.
96+
Task PostBuild {
97+
}
98+
99+
###############################################################################
100+
# Customize these tasks for performing operations before and/or after BuildHelp.
101+
###############################################################################
102+
103+
# Executes before the GenerateMarkdown phase of the BuildHelp task.
104+
Task PreBuildHelp {
105+
}
106+
107+
# Executes after the BuildHelpImpl phase of the BuildHelp task.
108+
Task PostBuildHelp {
109+
}
110+
111+
###############################################################################
112+
# Customize these tasks for performing operations before and/or after Install.
113+
###############################################################################
114+
115+
# Executes before the InstallImpl phase of the Install task.
116+
Task PreInstall {
117+
}
118+
119+
# Executes after the InstallImpl phase of the Install task.
120+
Task PostInstall {
121+
}
122+
123+
###############################################################################
124+
# Customize these tasks for performing operations before and/or after Publish.
125+
###############################################################################
126+
127+
# Executes before publishing occurs.
128+
Task PrePublish {
129+
}
130+
131+
# Executes after publishing occurs.
132+
Task PostPublish {
133+
}

src/Templates/NewModule/build.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# This builds this module by invoking the build.psake.ps1 script
1+
#Requires -Modules psake
22

3-
if ($null -eq (Get-Module -Name PSake -ListAvailable)) {
4-
throw "You need to install PSake before continuing. Install with 'Install-Module PSake -Scope CurrentUser'."
5-
}
6-
7-
Import-Module Psake
3+
# Builds the module by invoking psake on the build.psake.ps1 script.
84
Invoke-PSake $PSScriptRoot\build.psake.ps1 -taskList Build

0 commit comments

Comments
 (0)