You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of Update-ModuleManifest does not accept empty arguments for a number of parameters, meaning it can't be used to clear array-like values from existing manifests:
Instead of updating the manifest with RequiredModules = @(), this actually throws a validation error because -RequiredModules doesn't accept empty arguments.
I think that the concerned parameters should allow for both $Nulland an Empty Collection
In case the value is an (empty) collection, the value should convert to an (empty array) expression: @()
In case the value is $Null, the setting should reset to its original state:
For e.g. RequiredModules this means completely removing the concerned statement and replacing it with a comment: # RequiredModules = @()
For e.g. VariablesToExport assigning a wildcard (*), meaning replacing the statement with: VariablesToExport = '*'
functionUpdate-ModuleManifest {
param(
[AllowNull()]
[Object[]]$RequiredModules
)
if ($Null-eq$RequiredModules) {
Write-Host'Reset the setting to its original state'
}
else {
Write-Host'Convert the value to an expression'if (-not$RequiredModules) {
Write-Host'Even it is an empty collection'
}
}
}
PS C:\>Update-ModuleManifest-RequiredModules $Null
Reset the setting to its original state
PS C:\>Update-ModuleManifest-RequiredModules 1,2,3
Convert the value to an expression
PS C:\>Update-ModuleManifest-RequiredModules @()
Convert the value to an expression
Even it is an empty collection
Actually, it appears that there is a newer Update-PSModuleManifest (1.0.6) that does work as expected (except from the suggested $Null/Defaulting value):
Summary of the new feature / enhancement
The current implementation of
Update-ModuleManifest
does not accept empty arguments for a number of parameters, meaning it can't be used to clear array-like values from existing manifests:Instead of updating the manifest with
RequiredModules = @()
, this actually throws a validation error because-RequiredModules
doesn't accept empty arguments.This issue was initially raised here.
Proposed technical implementation details (optional)
Update the cmdlet in
src/code/UpdateModuleManifest.cs
.Parameters that should be decorated with
[AllowEmptyCollection]
:NestedModules
TypesToProcess
FormatsToProcess
ScriptsToProcess
RequiredAssemblies
FileList
ModuleList
FunctionsToExport
AliasesToExport
VariablesToExport
CmdletsToExport
DscResourcesToExport
CompatiblePSEditions
There's a number of additional parameters for which
[AllowNull]
/[AllowEmptyString]
might be appropriate too.The text was updated successfully, but these errors were encountered: