Skip to content

Test-ModuleManifest does not populate the NestedModules field #7833

Closed

Description

When I run the Test-ModuleManifest cmdlet with a psd1 file that has a NestedModules field, it returns null for NestedModules (even though the dll exists and is in the correct location). This results in Update-ModuleManifest commenting out the existing NestedModule fields when I try to update just the version. This is causing massive issues with our versioning scripts when trying to update from PowerShell 5.1 to PowerShell 6.0. Running this in PowerShell 5.1 with the same files works as expected. When I pulled down PowerShell to try to debug this, I saw that NestedModules was set correctly here: https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs#L2041, but not set in moduleInfo before moduleInfo was returned here: https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs#L2800.

Steps to reproduce

$a = Test-ModuleManifest -Path <path to module with filled out nestedmodules field>
$a.NestedModule # Returns nothing

Expected behavior

$a = Test-ModuleManifest -Path <path to module with filled out nestedmodules field>
$a.NestedModule # Returns correct Nested Modules

Actual behavior

Returns nothing


Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.0-preview.4
PSEdition                      Core
GitCommitId                    6.1.0-preview.4
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. iSazonov commented on Sep 21, 2018

    @iSazonov
    Collaborator

    Maddie Clayton (@maddieclayton) Please check with latest build like 6.1 GA.

  2. maddieclayton commented on Sep 21, 2018

    @maddieclayton
    Author

    Ilya (@iSazonov) Same issue with 6.1. I can also repro when I pull down PowerShell and build it locally.

  3. added
    Issue-Discussion
    on Sep 23, 2018
  4. maddieclayton commented on Sep 24, 2018

    @maddieclayton
    Author

    Ilya (@iSazonov) Ping - I can created a workaround for this using Set-Content, but I'd really like to use the Update-ModuleManifest as this is what the cmdlet was created for.

  5. iSazonov commented on Sep 25, 2018

    @iSazonov
    Collaborator

    Maddie Clayton (@maddieclayton) Thanks for update. Could you please compare with Get-Module result? Is there problem too?

  6. SteveL-MSFT commented on Sep 25, 2018

    @SteveL-MSFT
    Member

    Not repro'ing for me, need more detailed steps/information:

    PS /Users/steve/test> "" > foo.psm1                                                       
    PS /Users/steve/test> New-ModuleManifest -Path ./nestedmodule.psd1 -NestedModules foo.psm1
    PS /Users/steve/test> $a = Test-ModuleManifest ./nestedmodule.psd1                        
    PS /Users/steve/test> $a.NestedModules
    
    ModuleType Version    Name                                ExportedCommands
    ---------- -------    ----                                ----------------
    Script     0.0        foo                                 
  7. maddieclayton commented on Sep 25, 2018

    @maddieclayton
    Author

    Okay, I steadily copied over fields from the psd1 I was using into a new module manifest, and figured out where this issue is. If any of these fields are ' * ', the nested module will be correctly found, but if all are not ' * ', it will not find the nested module:

    # Functions 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 functions to export.
    FunctionsToExport = '*'
    
    # 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 = '*'
    

    Easiest repro I can get is:

    PS C:\Users\maclayto\Documents> New-ModuleManifest -Path ./nestedmodule1.psd1 -NestedModules foo.dll -FunctionsToExport @() -CmdletsToExport @() -VariablesToExport @() -AliasesToExport @()
    PS C:\Users\maclayto\Documents> $a = Test-ModuleManifest .\nestedmodule1.psd1
    PS C:\Users\maclayto\Documents> $a.NestedModules
    PS C:\Users\maclayto\Documents>
    

    Let me know if you can repro using these steps.

  8. SteveL-MSFT commented on Sep 25, 2018

    @SteveL-MSFT
    Member

    The detailed repro steps helped to isolate the root cause. Thanks!

  9. added
    Issue-Bug
    and removed
    Issue-Discussion
    on Sep 26, 2018
  10. added
    WG-Cmdlets
    and removed on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-BugResolution-FixedWG-Cmdlets

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions