Skip to content

Commit 11e1b94

Browse files
committed
Fixes #27. Allow overriding module output directory
$PSBPreference.Build.ModuleOutDir is now computed internally when Initialize-PSBuild is run as part of the 'Init' task. It should not be set directly.
1 parent 32cdae2 commit 11e1b94

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- `$PSBPreference.Build.CompileScriptHeader`
1616
- `$PSBPreference.Build.CompileScriptFooter`
1717

18+
### Fixed
19+
20+
- Overriding `$PSBPreference.Build.OutDir` now correctly determines the final module output directory. `$PSBPreference.Build.ModuleOutDir` is now computed internally and **SHOULD NOT BE SET DIRECTLY**. ` $PSBPreference.Build.OutDir` will accept both relative and fully-qualified paths.
21+
1822
## [0.4.0] - 2019-08-31
1923

2024
### Changed

Diff for: PowerShellBuild/PowerShellBuild.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
RootModule = 'PowerShellBuild.psm1'
3-
ModuleVersion = '0.4.0'
3+
ModuleVersion = '0.5.0'
44
GUID = '15431eb8-be2d-4154-b8ad-4cb68a488e3d'
55
Author = 'Brandon Olin'
66
CompanyName = 'Community'

Diff for: PowerShellBuild/Public/Initialize-PSBuild.ps1

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Initialize-PSBuild {
77
.PARAMETER BuildEnvironment
88
Contains the PowerShellBuild settings (known as $PSBPreference).
99
.PARAMETER UseBuildHelpers
10-
Use BuildHelpers module to popular common environment variables based on current build system context.
10+
Use BuildHelpers module to populate common environment variables based on current build system context.
1111
.EXAMPLE
1212
PS> Initialize-PSBuild -UseBuildHelpers
1313
@@ -22,6 +22,12 @@ function Initialize-PSBuild {
2222
[switch]$UseBuildHelpers
2323
)
2424

25+
if ([IO.Path]::IsPathFullyQualified($BuildEnvironment.Build.OutDir)) {
26+
$BuildEnvironment.Build.ModuleOutDir = [IO.Path]::Combine($BuildEnvironment.Build.OutDir, $env:BHProjectName, $BuildEnvironment.General.ModuleVersion)
27+
} else {
28+
$BuildEnvironment.Build.ModuleOutDir = [IO.Path]::Combine($env:BHProjectPath, $BuildEnvironment.Build.OutDir, $env:BHProjectName, $BuildEnvironment.General.ModuleVersion)
29+
}
30+
2531
$params = @{
2632
BuildOutput = $BuildEnvironment.Build.ModuleOutDir
2733
}
@@ -36,7 +42,8 @@ function Initialize-PSBuild {
3642

3743
if ($UseBuildHelpers.IsPresent) {
3844
$nl = [System.Environment]::NewLine
39-
"$nl`Environment variables:"
45+
46+
Write-Host "$nl`Environment variables:" -ForegroundColor Yellow
4047
(Get-Item ENV:BH*).Foreach({
4148
'{0,-20}{1}' -f $_.name, $_.value
4249
})

Diff for: PowerShellBuild/build.properties.ps1

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
2828
OutDir = $outDir
2929

3030
# Module output directory
31-
ModuleOutDir = "$outDir/$env:BHProjectName/$moduleVersion"
31+
# This will be computed in 'Initialize-PSBuild' so we can allow the user to
32+
# override the top-level 'OutDir' above and compute the full path to the module internally
33+
ModuleOutDir = $null
3234

3335
# Controls whether to "compile" module into single PSM1 or not
3436
CompileModule = $false

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ You can override these in either psake or Invoke-Build to match your environment
7575
| $PSBPreference.General.ModuleManifestPath | $env:BHPSModuleManifest | Path to the module manifest (PSD1)
7676
| $PSBPreference.Build.OutDir | $projectRoot/Output | Output directory when building the module
7777
| $PSBPreference.Build.Dependencies | 'StageFiles, 'BuildHelp' | Default task dependencies for the `Build` task
78-
| $PSBPreference.Build.ModuleOutDir | $outDir/$moduleName/$moduleVersion | Module output directory
78+
| $PSBPreference.Build.ModuleOutDir | $outDir/$moduleName/$moduleVersion | `For internal use only. Do not overwrite. Use '$PSBPreference.Build.OutDir' to set output directory`
7979
| $PSBPreference.Build.CompileModule | $false | Controls whether to "compile" module into single PSM1 or not
8080
| $PSBPreference.Build.CompileHeader | $false | String that appears at the top of your compiled PSM1 file
8181
| $PSBPreference.Build.CompileFooter | $false | String that appears at the bottom of your compiled PSM1 file

0 commit comments

Comments
 (0)