@@ -13,11 +13,6 @@ function GetBuildInfo {
13
13
14
14
$BuildInfo = if ($BuildManifest -and (Test-Path $BuildManifest )) {
15
15
if ((Split-path - Leaf $BuildManifest ) -eq ' build.psd1' ) {
16
- $BuildManifestParent = if ($BuildManifest ) {
17
- Split-Path - Parent $BuildManifest
18
- } else {
19
- Get-Location - PSProvider FileSystem
20
- }
21
16
# Read the Module Manifest configuration file for default parameter values
22
17
Write-Debug " Load Build Manifest $BuildManifest "
23
18
Import-Metadata - Path $BuildManifest
@@ -77,20 +72,34 @@ function GetBuildInfo {
77
72
78
73
$BuildInfo = $BuildInfo | Update-Object $ParameterValues
79
74
80
- # Resolve Module manifest if not defined in Build.psd1
81
- if (-Not $BuildInfo.SourcePath -and $BuildManifestParent ) {
82
- # Resolve Build Manifest's parent folder to find the Absolute path
83
- $ModuleName = Split-Path - Leaf $BuildManifestParent
75
+ $BuildManifestParent = if ($BuildManifest ) {
76
+ Split-Path - Parent $BuildManifest
77
+ } else {
78
+ Get-Location - PSProvider FileSystem
79
+ }
84
80
85
- # If we're in a "well known" source folder, look higher for a name
86
- if ($ModuleName -in ' Source' , ' src' ) {
87
- $ModuleName = Split-Path (Split-Path - Parent $BuildManifestParent ) - Leaf
81
+ # Resolve Module manifest if not defined in Build.psd1 or there's no Build.psd1
82
+ if (-Not $BuildInfo.SourcePath ) {
83
+ # Find a module manifest (or maybe several)
84
+ $ModuleInfo = Get-ChildItem $BuildManifestParent - Recurse - Filter * .psd1 - ErrorAction SilentlyContinue |
85
+ ImportModuleManifest - ErrorAction SilentlyContinue
86
+ # If we found more than one module info, the only way we have of picking just one is if it matches a folder name
87
+ 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
93
+ }
94
+ $ModuleInfo = @ ($ModuleInfo ).Where { $_.Name -eq $ModuleName }
95
+ }
96
+ if (@ ($ModuleInfo ).Count -eq 1 ) {
97
+ Write-Debug " Updating BuildInfo SourcePath to $SourcePath "
98
+ $BuildInfo = $BuildInfo | Update-Object @ { SourcePath = $ModuleInfo.Path }
99
+ }
100
+ if (-Not $BuildInfo.SourcePath ) {
101
+ throw " Can't find a module manifest in $BuildManifestParent "
88
102
}
89
-
90
- # As the Module Manifest did not specify the Module manifest, we expect the Module manifest in same folder
91
- $SourcePath = Join-Path $BuildManifestParent " $ModuleName .psd1"
92
- Write-Debug " Updating BuildInfo SourcePath to $SourcePath "
93
- $BuildInfo = $BuildInfo | Update-Object @ { SourcePath = $SourcePath }
94
103
}
95
104
96
105
# Make sure the Path is set and points at the actual manifest, relative to Build.psd1 or absolute
0 commit comments