PowerShellGetv2
PowerShellGetv2 copied to clipboard
Update-ModuleManifest converts empty array @() to asterisk '*'
Steps to reproduce
- create a module manifest with default values for
CmdletsToExport, andAliasesToExport
snippet from foo.psd1:
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
- update an unrelated field
Update-ModuleManifest -Path ./foo.psd1 -Prerelease 'foo'
Expected behavior
snippet from updated foo.psd1 remains the same:
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
Actual behavior
snippet from updated foo.psd1 has modified values for CmdletsToExport and AliasesToExport:
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'
Environment data
Name Value
---- -----
PSVersion 6.2.2
PSEdition Core
GitCommitId 6.2.2
OS Darwin 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
@eedwards-sk Please move the issue to PowerShellGet repo.
/cc @SteveL-MSFT for information.
Workaround is to use Update-ModuleManifest -Path $ModuleManiFestPath -AliasesToExport @($null) -FunctionsToExport @($null) -CmdletsToExport @($null).
However -VariablesToExport @($null) wont work since VariablesToExport parameter have the attribute [ValidateNotNullOrEmpty()] which Aliases, Functions and Cmdlets does not have.
My suggestion is to remove the attribute [ValidateNotNullOrEmpty()] from the VariablesToExport parameter and add "-or $VariablesToExport -is [array]" to the if($VariablesToExport) to better align with how Aliases, Functions and Cmdlets to export works.
Thumbs up if you want a Pull Request with this.