@@ -2,15 +2,7 @@ function GetBuildInfo {
2
2
[CmdletBinding ()]
3
3
param (
4
4
# The path to the Build Manifest Build.psd1
5
- [Parameter (Mandatory )]
6
- [ValidateScript ( {
7
- if ((Test-Path $_ ) -and (Split-path - Leaf $_ ) -eq ' build.psd1' ) {
8
- $true
9
- }
10
- else {
11
- throw " The Module Manifest must point to a valid build.psd1 Data file"
12
- }
13
- })]
5
+ [Parameter ()][AllowNull ()]
14
6
[string ]$BuildManifest ,
15
7
16
8
# Pass MyInvocation from the Build-Command so we can read parameter values
@@ -19,9 +11,23 @@ function GetBuildInfo {
19
11
$BuildCommandInvocation
20
12
)
21
13
22
- # Read the Module Manifest configuration file for default parameter values
23
- Write-Debug " Load Build Manifest $BuildManifest "
24
- $BuildInfo = Import-Metadata - Path $BuildManifest
14
+ $BuildInfo = if ($BuildManifest -and (Test-Path $BuildManifest )) {
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
+ # Read the Module Manifest configuration file for default parameter values
22
+ Write-Debug " Load Build Manifest $BuildManifest "
23
+ Import-Metadata - Path $BuildManifest
24
+ } else {
25
+ @ { SourcePath = $BuildManifest }
26
+ }
27
+ } else {
28
+ @ {}
29
+ }
30
+
25
31
$CommonParameters = [System.Management.Automation.Cmdlet ]::CommonParameters +
26
32
[System.Management.Automation.Cmdlet ]::OptionalCommonParameters
27
33
$BuildParameters = $BuildCommandInvocation.MyCommand.Parameters
@@ -71,9 +77,6 @@ function GetBuildInfo {
71
77
72
78
$BuildInfo = $BuildInfo | Update-Object $ParameterValues
73
79
74
- # Resolve Build Manifest's parent folder to find the Absolute path
75
- $BuildManifestParent = (Split-Path - Parent $BuildManifest )
76
-
77
80
# Resolve Module manifest if not defined in Build.psd1
78
81
if (-Not $BuildInfo.SourcePath -and $BuildManifestParent ) {
79
82
# Resolve Build Manifest's parent folder to find the Absolute path
0 commit comments