8000 Test-ModuleManifest erroneously requires a script-module RootModule entry to be specified with filename extension · Issue #8388 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

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

@mklement0

Description

@mklement0

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)

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-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0