I'm having a minor issue with nested, PowerShell modules.
Get-Module
correctly identifies the ExportedCommands
, but the ModuleType
is listed as Script
, rather than Manifest
:
PS>get-module
ModuleType Name ExportedCommands
---------- ---- ----------------
Script Bar Get-Bar
Script Foo Get-Foo
Directory structure:
|-Modules
|-Foobar
|-Foobar.psd1
|-Bar
|-Bar.psm1
|-Foo
|-Foo.psm1
Foobar.psd1:
...
# Script module or binary module file associated with this manifest
ModuleToProcess = ''
# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = 'Foo\Foo.psm1', 'Bar\Bar.psm1'
...
Have I structured the PSD1 file correctly? In my situation, do I need a dummy/empty Foobar.psm1 file (with corresponding entry in PSD1 file)? Do I need the nested directory structure, or can I just include the two PSM1 files (bar.psm1 and foo.psm1) in the parent directory (Foobar)?
To create and use a module manifest The best practice to create a module manifest is to use the New-ModuleManifest cmdlet. You can use parameters to specify one or more of the manifest's default keys and values. The only requirement is to name the file.
File used by Windows PowerShell, a shell program that includes more advanced features than the Windows Command Prompt; contains various configuration information for a PowerShell script or module. PSD1 files are used for storing module manifest information in hash table format.
The New-ModuleManifest cmdlet creates a new module manifest ( . psd1 ) file, populates its values, and saves the manifest file in the specified path. Module authors can use this cmdlet to create a manifest for their module.
Starting in PowerShell 3.0, installed modules are automatically imported to the session when you use any commands or providers in the module. However, you can still use the Import-Module command to import a module. You can disable automatic module importing using the $PSModuleAutoloadingPreference preference variable.
Directory structure needed to be:
|-Modules
|-Foobar
|-Foobar.psd1
|-Bar.psm1
|-Foo.psm1
Foobar.psd1 needed to be :
...
# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = 'Foo.psm1', 'Bar.psm1'
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With