New-ModuleManifest m.psd1 -RequiredModules sub
Test-ModuleManifest m.psd1 -verbose
Note that it tries to load every version of every module.
This is being used by psake build scripts, making them almost unusable.
Performance very similar to
New-ModuleManifest m.psd1
Test-ModuleManifest m.psd1 -verbose
measure-command {Test-ModuleManifest m.psd1}
Days : 0
Hours : 0
Minutes : 0
Seconds : 54
Milliseconds : 312
Ticks : 543125777
TotalDays : 0,000628617797453704
TotalHours : 0,0150868271388889
TotalMinutes : 0,905209628333333
TotalSeconds : 54,3125777
TotalMilliseconds : 54312,5777
Name Value
---- -----
PSVersion 5.1.15063.138
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.138
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
This repros on Windows PowerShell 5.1 for me, but not in PSCore6 where I have the same PSModulePath from 5.1
PS C:\users\slee\repos> measure-command {New-ModuleManifest m.psd1 -requiredmodules sub; Test-ModuleManifest m.psd1}
Test-ModuleManifest : The specified RequiredModules entry 'sub' in the module manifest 'C:\users\slee\repos\m.psd1' is
invalid. Try again after updating this entry with valid values.
At line:1 char:66
+ ... duleManifest m.psd1 -requiredmodules sub; Test-ModuleManifest m.psd1}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (m.psd1:String) [Test-ModuleManifest], DirectoryNotFoundException
+ FullyQualifiedErrorId : Modules_InvalidRequiredModulesinModuleManifest,Microsoft.PowerShell.Commands.TestModuleM
anifestCommand
Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 351
Ticks : 3518615
TotalDays : 4.07247106481481E-06
TotalHours : 9.77393055555556E-05
TotalMinutes : 0.00586435833333333
TotalSeconds : 0.3518615
TotalMilliseconds : 351.8615
Would still be nice to fix on Windows, right?
@powercode the unfortunate reality is that fixing an issue in the in-box Windows PowerShell is a much more involved process than fixing something on GitHub. At this time we are really only taking security fixes for Windows PowerShell and focusing our engineering efforts on PSCore6.
So the workaround I found was that you have to call the Install-Module for each dependent module BEFORE attempting to publish the module with dependencies.
The other way to work around this is to rely on the #Requires in the psm1 argument instead of RequiredModules in the psd1.
#Requires -modules Module1,Module2,Module3
While this does break the auto install of RequiredModules during the Install-Module it does solve the Test-ModuleManifest issue and causes psake to function as expected during build.
One last approach worth mentioning is that you can temporarily change the $ENV:PSModulePath to a folder where you download your required modules. I have used this to work around the import issue.
@SteveL-MSFT - You said that you could reproduce this error on PowerShell version 5.1 but it works for you on PowerShell 6? I'm not having the same luck. Running PowerShell version 6.0.4 on a Docker container on Ubuntu 16.04 and running PowerShell version 6.0.4 on Windows Server 2016, throws the DirectoryNotFoundException error when running Test-ModuleManifest if I don't install the required modules first. Did you do the workaround of installing all of the dependent modules to get it work?