PowerShellGet cannot publish modules with dependencies to galleries which require credentials #142
Description
If a gallery requires Credentials
for search, PowerShellGet cannot publish modules to that gallery if they have RequiredModules which are not external.
Expected Behavior
Publish-Module should publish modules, as long as their dependencies are either available on the repository being published to, or marked external.
Current Behavior
PowerShellGet cannot resolve the module dependency
Possible Solution
Pass credentials through to the dependency check
Steps to Reproduce (for bugs)
- Create two modules, where one depends on the other.
- Set up a repository where credentials are required for search and install.
- Attempt to publish both modules
Context
After the fixes described in the workaround for #133 we have been successfully using Visual Studio Online as a PowerShell repository. Now we need to publish modules which have dependencies, and we've found that the dependency check that PowerShellGet does does not pass the credentials through (even though it does pass the credentials to the Find-Module which tests to see if the module's already published, it does not pass them to Get-ModuleDependencies
For example:
<#1#> Get-Module Q* -list | Format-Table Name, RequiredModules
Name RequiredModules
---- ---------------
Questionmark.Assemblies {Microsoft.PowerShell.Utility}
Questionmark.Database {Questionmark.Assemblies}
In the first one, I've marked Microsoft.PowerShell.Utility
as an ExternalModuleDependencies
-- even though I think PowerShellGet should be smart enough to figure out the built-in modules are ... built-in.
When I try to publish, this happens:
<#2#> Publish-Module -Name Questionmark.Assemblies -Repository QM -NuGetApi BUG -Cred $cred
<#3#> Publish-Module -Name Questionmark.Database -Repository QM -NuGetApi BUG-Cred $cred
Publish-PSArtifactUtility : PowerShellGet cannot resolve the module dependency
'Questionmark.Assemblies' of the module 'Questionmark.Database' on the repository 'QM'.
Verify that the dependent module 'Questionmark.Assemblies' is available in the repository 'QM'.
If this dependent module 'Questionmark.Assemblies' is managed externally, add it to the
ExternalModuleDependencies entry in the PSData section of the module manifest.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.2.0\PSModule.psm1:1227 char:17
+ Publish-PSArtifactUtility -PSModuleInfo $moduleInfo `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Publish-PSArtifactUtility], InvalidOperationException
+ FullyQualifiedErrorId : UnableToResolveModuleDependency,Publish-PSArtifactUtility
<#4#> Find-Module -Name Questionmark.Assemblies -Repository PoshCode -Credential $cred
Version Name Repository Description
------- ---- ---------- -----------
17.6.99... Questionmark.Assemblies PoshCode A dependency module for loading the assemblies commonly needed by Questionmark modules
PowerShellGet version 1.1.2