question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publish-PSResource does not take into account ExternalModuleDependencies, when checking dependencies

See original GitHub issue

Prerequisites

  • 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:closed
  • Created 2 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
peetrikecommented, Jul 14, 2023

I would expect this to be an easy fix when publishing to exclude any required modules if it also exists in the external modules.

This is also the way, how Publish-Script works now.

1reaction
ThomasNietocommented, Jul 14, 2023

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found