Skip to content

Test-ModuleManifest erroneously requires a script-module RootModule entry to be specified with filename extension #8388

Description

This is a regression from Windows PowerShell.

In PS Core, a *.psm1 file referenced in a module manifest's RootModule entry must be specified with the filename extension in order for Test-ModuleManifest to consider the manifest valid.

This is at odds with:

  • current Windows PowerShell behavior

  • and, more importantly, the fact that this is not an actual requirement for being able to import and use a module.

Moreover, the error message that is issued when the extension is missing is misleading: see #6683

Steps to reproduce

# Create a manifest whose RootModule entry is a filename *without the .psm1 extension*
New-ModuleManifest (Join-Path (New-Item -Force -Type Directory tmpMod) tmpMod.psd1) -RootModule tmpMod -function foo
# Create the *.psm1 file
'function foo { "foo" }' > tmpMod/tmpMod.psm1
# Import the module and call one of its functions.
Import-Module ./tmpMod
foo
# Validate the manifest.
Test-ModuleManifest tmpMod/tmpMod.psd1

Expected behavior

foo

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.0.1      tmpMod                              foo

Actual behavior

foo

Test-ModuleManifest : The module manifest 'tmpMod' could not be processed 
because it is not a valid PowerShell module manifest file. 
Remove the elements that are not permitted: /path/to/tmpMod/tmpMod.psd1

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.0.1      tmpMod                              foo

That is, Test-ModuleManifest unexpectedly claims that the manifest is invalid, even though it clearly isn't, as evidenced by the module having been successfully imported.

Environment data

PowerShell Core 6.2.0-preview.1 on macOS 10.14.1
PowerShell Core 6.2.0-preview.1 on Ubuntu 16.04.5 LTS
PowerShell Core 6.2.0-preview.1 on Microsoft Windows 10 Pro (64-bit; Version 1803, OS Build: 17134.345)

Activity

  1. pougetat commented on Jan 11, 2019

    @pougetat

    Hey Michael Klement (@mklement0) ,
    Do you mind if I work on this bug ?
    :)

  2. mklement0 commented on Jan 11, 2019

    @mklement0
    ContributorAuthor

    pougetat (@pougetat): I'm personally happy for you to take this on, but since the issue hasn't been marked as up-for-grabs (yet), let's ask the powers that be; Steve Lee (@SteveL-MSFT)?

  3. pougetat commented on Jan 11, 2019

    @pougetat

    Sounds good. I'll pick this up as a habit going forward.

  4. added
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions