New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mklement0 opened this Issue Dec 3, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@mklement0
Contributor

mklement0 commented Dec 3, 2018

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment