@@ -65,10 +65,13 @@ function GetBuildInfo {
6565 }
6666 # BuildInfo.SourcePath should point to a module manifest
6767 if ($BuildInfo.SourcePath -and $BuildInfo.SourcePath -ne $BuildManifest ) {
68+ Write-Debug " Updating: SourcePath"
69+ Write-Debug " To: $ ( $BuildInfo.SourcePath ) "
6870 $ParameterValues [" SourcePath" ] = $BuildInfo.SourcePath
6971 }
7072 # If SourcePath point to build.psd1, we should clear it
7173 if ($ParameterValues [" SourcePath" ] -eq $BuildManifest ) {
74+ Write-Debug " Removing: SourcePath"
7275 $ParameterValues.Remove (" SourcePath" )
7376 }
7477 Write-Debug " Finished parsing Build Manifest $BuildManifest "
@@ -80,25 +83,31 @@ function GetBuildInfo {
8083 }
8184
8285 if ((-not $BuildInfo.SourcePath ) -and $ParameterValues [" SourcePath" ] -notmatch ' \.psd1' ) {
86+ Write-Debug " Searching: SourcePath"
8387 # Find a module manifest (or maybe several)
8488 $ModuleInfo = Get-ChildItem $BuildManifestParent - Recurse - Filter * .psd1 - ErrorAction SilentlyContinue |
8589 ImportModuleManifest - ErrorAction SilentlyContinue
8690 # If we found more than one module info, the only way we have of picking just one is if it matches a folder name
8791 if (@ ($ModuleInfo ).Count -gt 1 ) {
88- # Resolve Build Manifest's parent folder to find the Absolute path
89- $ModuleName = Split-Path - Leaf $BuildManifestParent
90- # If we're in a "well known" source folder, look higher for a name
91- if ($ModuleName -in ' Source' , ' src' ) {
92- $ModuleName = Split-Path (Split-Path - Parent $BuildManifestParent ) - Leaf
92+ Write-Debug (@ (@ (" Found $ ( @ ($ModuleInfo ).Count) :" ) + @ ($ModuleInfo.Path )) -join " `n " )
93+ # It can't be a module that needs building unless it has either:
94+ $ModuleInfo = $ModuleInfo.Where {
95+ $Root = Split-Path $_.Path
96+ @ (
97+ # - A build.psd1 next to it
98+ Test-Path (Join-Path $Root " build.ps1" ) - PathType Leaf
99+ # - A Public (or Private) folder with source scripts in it
100+ Test-Path (Join-Path $Root " Public" ) - PathType Container
101+ Test-Path (Join-Path $Root " Private" ) - PathType Container
102+ ) -contains $true
93103 }
94- $ModuleInfo = @ ($ModuleInfo ).Where { $_ .Name -eq $ModuleName }
104+ Write-Debug ( @ ( @ ( " Filtered $ ( @ ($ModuleInfo ).Count ) : " ) + @ ( $ModuleInfo .Path )) -join " `n " )
95105 }
96106 if (@ ($ModuleInfo ).Count -eq 1 ) {
97107 Write-Debug " Updating BuildInfo SourcePath to $ ( $ModuleInfo.Path ) "
98108 $ParameterValues [" SourcePath" ] = $ModuleInfo.Path
99- }
100- if (-Not $ModuleInfo ) {
101- throw " Can't find a module manifest in $BuildManifestParent "
109+ } else {
110+ throw " Can't determine the module manifest in $BuildManifestParent "
102111 }
103112 }
104113
0 commit comments