Open ykuijs opened 1 year ago
I can reproduce it, but had to add DscBuildHelpers
to the RequiredModules.psd1. Also added xDscResourceDesigner just to verify it still failed, and added PowerShellGet to get the latest version since my macOS has 2.2.3 installed instead of 2.2.5. But made no difference.
DscBuildHelpers = 'latest'
xDscResourceDesigner = 'latest'
PowerShellGet = 'latest'
So the code you are referring looks like it is meant to "copy" a required module that is listed in the module manifest from a path of $PSModulePath
to output
but only if it is not already available in output
. It does the "copying" by adding a local folder (PS)Repository, if it does not find the module in the local folder repository it tries to find it in $PSModulePath
then it publishes it to the local folder repository. Honestly, I do not know why it need to do that. That locally published module does not seem to be published to the Gallery together with the actual module anyway. I'm thinking this is old code that have no purpose no longer. 🤔
The reason it fails seems to be that (at least in macOS) it does not work using a local folder repository. I can't get Find-Module
to work:
/Users/johlju/source/HelpUsers/debug-sampler/MySimpleModule> $RepositoryParams = @{
>> Name = 'output'
>> SourceLocation = (Resolve-Path -Path './output/RequiredModules').Path + '/'
>> PublishLocation = (Resolve-Path -Path './output/RequiredModules').Path + '/'
>> ErrorAction = 'Stop'
>> }
/Users/johlju/source/HelpUsers/debug-sampler/MySimpleModule> Register-PSRepository @RepositoryParams
/Users/johlju/source/HelpUsers/debug-sampler/MySimpleModule> Get-PSRepository
Name InstallationPolicy SourceLocation
---- ------------------ --------------
output Untrusted /Users/johlju/source/HelpUsers/debug-sampler/MySimpleModule/output/RequiredModule…
PSGallery Untrusted https://www.powershellgallery.com/api/v2
/Users/johlju/source/HelpUsers/debug-sampler/MySimpleModule> (Get-PSRepository).SourceLocation
/Users/johlju/source/HelpUsers/debug-sampler/MySimpleModule/output/RequiredModules/
https://www.powershellgallery.com/api/v2
/Users/johlju/source/HelpUsers/debug-sampler/MySimpleModule> ls (Get-PSRepository).SourceLocation[0]
ChangelogManagement Metadata PackageManagement PowerShellGet xDSCResourceDesigner
Configuration ModuleBuilder Pester Sampler
DscBuildHelpers PSDepend Plaster Sampler.GitHubTasks
InvokeBuild PSScriptAnalyzer PowerShellForGitHub powershell-yaml
/Users/johlju/source/HelpUsers/debug-sampler/MySimpleModule> Find-Module -Name 'Sampler' -repository output -ErrorAction Stop
Find-Package: No match was found for the specified search criteria and module name 'Sampler'. Try Get-PSRepository to see all available
registered module repositories.
Also, there is a bug that if this code should actually be there, it should handle unregister the output
repository whenever the task fails. The repository name output
should probably be sampler_pack_output
or something that is not likely for a user to have named one (since we unregistering it).
Problem description
I create a new module based on Sampler using this code:
When I configure this module to require a module that in turns requires another module, the Pack step fails with the error that the dependency cannot be resolved. When I remove the entry from the RequiredModules property or add modules that do not have any RequiredModules themselves, all works well.
I have traced back the error to these lines of code: https://github.com/gaelcolas/Sampler/blob/b2fc9fb6841108304ca16b80c57f6f51535defc8/.build/tasks/release.module.build.ps1#L296-L313 These lines are causing the issue. When I remove them, the Pack step runs as expected. So, not sure why the Required Modules need to get published before publishing the actual module.
Verbose logs
How to reproduce
New-SampleModule @newSampleModuleParameters
PowerShell version and build the target node is running
Module version used