Publish-PSResource does not take into account ExternalModuleDependencies, when checking dependencies
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
Steps to reproduce
New-PSScriptFileInfo -Description 'just for test' -RequiredModules @{ModuleName='Hyper-V'} -ExternalModuleDependencies 'Hyper-V' -Path test.ps1
Publish-PSResource -Path .\test.ps1 -Repository local
Expected behavior
script is published
Actual behavior
publish-psresource : Dependency 'Hyper-V' was not found in repository 'local'. Make sure the dependency is published to the repository before publishing this module.
Error details
Exception :
Type : System.ArgumentException
Message : Dependency 'Hyper-V' was not found in repository 'local'. Make sure the dependency is published to the repository before publishing this module.
HResult : -2147024809
CategoryInfo : ObjectNotFound: (:) [Publish-PSResource], ArgumentException
FullyQualifiedErrorId : DependencyNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.PublishPSResource
InvocationInfo :
MyCommand : Publish-PSResource
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 297
Line : Publish-PSResource -Path .\test.ps1 -Repository local
PositionMessage : At line:1 char:1
+ Publish-PSResource -Path .\test.ps1 -Repository local
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Publish-PSResource
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
Environment data
PSResourceGet: 0.5.22 PowerShell: 5.1 and 7.3.5
Visuals
No response
Issue Analytics
- State:
- Created 2 months ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Unable to Publish PowerShell Module to Local Repo that is ...
This answer on PowerShell.org indicated that the ExternalModuleDependencies property (that I generated through the Update-ModuleManifest cmdlet) ...
Read more >Can't get ExternalModuleDependencies working · Issue #164
I cant figure out how to add ExternalModuleDependencies as a Parameter to the New-Modulemanifest cmdlet. Question: is there no way to add ...
Read more >How to cause Install-Module to also install any required ...
The problem is that when I install this module I get the following warning: WARNING: The externally managed, dependent module 'SqlServer' is ......
Read more >ExternalModuleDependencies Errors : r/PowerShell
I have a PowerShell module that I want to auto increment when I publish it with publish-module. I am attempting to autoincrement the...
Read more >Resolving PowerShell module assembly dependency ...
This is a solution to use when confronted with a module that won't work due to an existing dependency conflict. Dependency conflicts occur ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is also the way, how
Publish-Script
works now.A common use case would be to define the required module and then if that module is already installed on the system as a built in module (not available on the gallery) to add it to external module dependencies to be a conditional exclusion.
The required module is necessary to have PowerShell check and auto load that module first. If the user only had it in external required modules it does not benefit from PowerShell checking dependencies on import.
I would expect this to be an easy fix when publishing to exclude any required modules if it also exists in the external modules.