Skip to content

Metadata not usable with boolean values #1

@misterfoo

Description

@misterfoo

With the latest version of this code (looks like it was recently refactored out of Configuration) a metadata value that's set to $true or $false doesn't get propagated correctly. This is causing Build-Module to behave unexpectedly.

Use case: Invoke Build-Module with inputs coming from a metadata file.
Expected: Builder places output in a version directory (e.g. /wherever/MyModule/1.2.3).
Observed: Builder does not find a value for VersionedOutputDirectory and ultimately does not place output in a version directory (output goes to /wherever/MyModule).

Metadata file contents:

@{
	Path = "MyModule.psd1"
	OutputDirectory = "..\bin\MyModule"
	SourceDirectories = 'Classes','Private','Public'
	PublicFilter = 'Public\*.ps1'
	VersionedOutputDirectory = $true
}

Output from Build-Module -Debug:

DEBUG: ConvertFrom-Metadata: Replaced true in metadata: @{
 Path = "EmsAutomatedTests.psd1"
 OutputDirectory = "..\bin\EmsAutomatedTests"
 SourceDirectories = 'Classes','Private','Public'
 PublicFilter = 'Public\*.ps1'
 VersionedOutputDirectory = ${__Metadata__true__}
 CopyPaths = "Resources"
}
[...snip...]
DEBUG: ConvertFrom-Metadata: Setting __Metadata__PSScriptRoot__ = D:\a\1\s\EmsAutomatedTests\Source
DEBUG: ConvertFrom-Metadata: Setting __Metadata__ScriptRoot__ = D:\a\1\s\EmsAutomatedTests\Source
DEBUG: ConvertFrom-Metadata: Setting __Metadata__PoshCodeModuleRoot__ = D:\a\1\s\EmsAutomatedTests\Source
DEBUG:   Parameter: SourcePath
DEBUG:     ... Update BuildInfo[SourcePath] from Path
DEBUG:     From Manifest: EmsAutomatedTests.psd1
DEBUG:   Parameter: OutputDirectory
DEBUG:     From Manifest: ..\bin\EmsAutomatedTests
DEBUG:   Parameter: VersionedOutputDirectory
DEBUG:   Parameter: UnversionedOutputDirectory
DEBUG:   Parameter: SemVer
DEBUG:   Parameter: Version
DEBUG:   Parameter: Prerelease
DEBUG:   Parameter: BuildMetadata
DEBUG:   Parameter: CopyPaths
DEBUG:     From Manifest: Resources
DEBUG:   Parameter: SourceDirectories
DEBUG:     From Manifest: Classes, Private, Public
DEBUG:   Parameter: PublicFilter
DEBUG:     From Manifest: Public\*.ps1
DEBUG:   Parameter: IgnoreAliasAttribute
DEBUG:   Parameter: Encoding
DEBUG:     From Default: UTF8
DEBUG:   Parameter: Prefix
DEBUG:   Parameter: Suffix
DEBUG:   Parameter: Target
DEBUG:     From Default: CleanBuild
DEBUG:   Parameter: Passthru
DEBUG: Finished parsing Build Manifest

This seems related to the following code, but I could be mistaken:

# Set the __Metadata__ValidVariables__ in our scope but not for constant variables:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions