If I create a manifest module with nested modules, exported functions from all nested modules after the first do not appear in the list of available commands and don\'t trigger
Hy Paul, Hy Luken,
After struggling for a few hours on this topic (with the implicit and declared manifest approach), I opted for the auto generated manifest. In essence, I wrote a ps1 script that generates the manifest, in two steps:
IMHO, Advantage of that approach: I 'fully' understand and master the exposure of the module content.
below you can find a PS code snippet that follows this approach, hoping it will benefit to other people.
# module discovery
$rootModule = "WdCore";
$modules = Get-ChildItem *.psm1;
$nestedmodulesNames = $modules | where { $_.BaseName -ne "WdCore"} | % { $_.BaseName } ;
# functions discovery
$modulesLines = $modules | Get-Content;
$functionsLines = $modulesLines | where { $_.contains("Function") };
$functionNamePattern = '^Function\s+(?([a-z][0-9|A-Z|-]+))\s?{.*$';
$functionNames = $functionsLines | where { $_ -match $functionNamePattern } | select { $Matches['name'] } | % { $_.' $Matches[''name''] '};
# generate manifest
New-ModuleManifest `
-Path ./WdTools.psd1 -RootModule $rootModule `
-ModuleVersion '1.0' `
-NestedModules $nestedmodulesNames `
-FunctionsToExport $functionNames `
-Guid '57D7F213-2316-4786-8D8A-3E4B9262B1E5' `
-Author 'Blaise Braye' `
-Description 'This module provides working directory tooling' `
-PowerShellVersion '3.0' -ClrVersion '4.0';