为嵌套的PowerShell模块创建清单

cra*_*aig 6 powershell powershell-2.0

嵌套的PowerShell模块出现了一个小问题。

Get-Module正确标识ExportedCommands,但ModuleType列为Script,而不是Manifest

PS>get-module

ModuleType Name                      ExportedCommands
---------- ----                      ----------------
Script     Bar                       Get-Bar
Script     Foo                       Get-Foo
Run Code Online (Sandbox Code Playgroud)

目录结构:

|-Modules
  |-Foobar
    |-Foobar.psd1
    |-Bar
      |-Bar.psm1
    |-Foo
      |-Foo.psm1
Run Code Online (Sandbox Code Playgroud)

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'
...
Run Code Online (Sandbox Code Playgroud)

我是否正确构造了PSD1文件?在我的情况下,我是否需要一个虚拟/空的Foobar.psm1文件(在PSD1文件中具有相应的条目)?我需要嵌套的目录结构,还是可以在父目录(Foobar)中仅包含两个PSM1文件(bar.psm1和foo.psm1)?

cra*_*aig 6

目录结构必须为:

|-Modules
  |-Foobar
    |-Foobar.psd1
    |-Bar.psm1
    |-Foo.psm1
Run Code Online (Sandbox Code Playgroud)

Foobar.psd1必须为:

...
# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = 'Foo.psm1', 'Bar.psm1'
...
Run Code Online (Sandbox Code Playgroud)