Test-ModuleManifest should check the manifest / root-module file base name for naming consistency with the enclosing directory #8391
Labels
Issue-Enhancement
the issue is more of a feature request than a bug
Resolution-No Activity
Issue has had no activity for 6 months or more
WG-Cmdlets-Core
cmdlets in the Microsoft.PowerShell.Core module
For a module to be picked up merely by the name of its containing directory, its manifest must have the same name as that directory; e.g., a module directory
foo
must contain a manifest namedfoo.psd1
.Auto-loading and discovery of not-yet-loaded modules relies on this convention.
There are two pitfalls, both of which
Test-ModuleManifest
should detect, but currently doesn't:(a) Your
*.psd1
file's base name may differ from the enclosing directory name (assuming that your root*.psm1
file doesn't match the name either), so loading the module by its directory name / path will fail.(b) A
*.psm1
file that matches the enclosing directory name may be present, but the*.psd1
file may have a different name, in which case loading the module by directory name will use the*.psm1
directly, bypassing the manifest altogether.Steps to reproduce
Scenario (a)
Scenario (b)
Expected behavior
Scenario (a)
Test-ModuleManifest
should report an error that the*.psd1
file's base name doesn't match the name of the enclosing directory.Scenario (b)
Test-ModuleManifest
should report an error or at least warn that no*.psd1
file (manifest) with the expected name was found, only a*.psm1
file.Actual behavior
Scenario (a)
Test-ModuleManifest
succeeds.Scenario (b)
Test-ModuleManifest
succeeds, and the verbose output indicates that it was the*.psm1
file rather than the manifest (*.psd1
) that was imported (and would be withImport-Module
).Environment data
The text was updated successfully, but these errors were encountered: