This topic contains 3 replies, has 2 voices, and was last updated by
August 10, 2018 at 10:03 pm #108239
We are moving our standalone scripts into modules. We have created a module that uses nested modules. The module itself is just a utility that contains the nested modules. The structure is like this:
In the manifest we have set up the nested module information like so
NestedModules = @('DoSomething\Get-Something.psm1')
FunctionsToExport = '*'
# ModuleList = @()
Test-ModuleManifest says everything is fine. Using Import-Module to load the module works. Get-Command -Module Utility displays the command(s) correctly. Executing them works. So as far as I can tell everything is working correctly.
Now we generate a NuGet package for the module and upload it to our private gallery. I am able to see the module in the repo via Find-Module. I am able to install it using Install-Module. I go to the %Program Files%\WindowsPowershell\modules path and it has properly extracted it to the required layout that is recommended. Everything looks great.
Now I try to run Import-Module and I get the error – import-module : The specified module 'Fsmb.Utility' was not loaded because no valid module file was found in any
Trying to use Get-Command on the module shows no commands.
What would be preventing this from working when installed via a repo vs importing it directly?
Note that I've also tried setting (in the manifest) ModuleList to the same set of values as NestedModules. It had no effect. Since redeploying to the repo is a pain I simply edited the .psd1 file that was installed into the folder mentioned earlier. So unless PS is caching the manifest data somewhere it should have detected the module list.
August 13, 2018 at 7:49 pm #108413ParticipantPoints: 46Rank: Member
Take a look at this article for guidance to make sure you are correctly packaging your modules.
August 16, 2018 at 1:43 pm #108697
That looks like what I've already done. Again, the layout is identical when I build out the module on disk and when it gets installed via the gallery. The only difference between the 2 is the target location. When importing/testing the module in the local directory it works fine. It only fails (with the same exact directory structure and manifest) when it is installed via the gallery.
August 16, 2018 at 7:17 pm #108745
I have figured out what is going wrong. The module is being hosted in a NuGet repository that has been configured. In the nuspec file it is using semantic versioning (e.g. 1.2. 3) since that is what NuGet uses. However in the generated manifest file it uses a full version number (e.g. 18.104.22.168).
When the module is installed it generates a folder structure that uses the semantic version #. When PowerShell tries to find the module it is using the full version and isn't finding it so it fails.
The fix is to ensure that both the Nuspec and manifest file are using the same semantic version (e.g. 1.2.3).
The topic ‘Issue Importing Module from Gallery’ is closed to new replies.