Skip to content

Install-PSResource fails with ExternalModuleDependencies #1809

Closed

Description

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

Install-PSResource AnyPackage.Appx

Expected behavior

Module installs successfully

Actual behavior

Install fails due to it not properly checking ExternalModuleDependencies

Error details

Exception             :
    Type    : Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceNotFoundException
    Message : Package(s) 'anypackage.appx' could not be installed from repository 'PSGallery'.
    HResult : -2146233088
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
CategoryInfo          : InvalidData: (Microsoft.PowerShel…s.InstallPSResource:InstallPSResource) [Install-PSResource],
ResourceNotFoundException
FullyQualifiedErrorId : InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
InvocationInfo        :
    MyCommand        : Install-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 3
    Line             : Install-PSResource anypackage.appx -Verbose -TrustRepository
    Statement        : Install-PSResource anypackage.appx -Verbose -TrustRepository
    PositionMessage  : At line:1 char:1
                       + Install-PSResource anypackage.appx -Verbose -TrustRepository
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Install-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
      0
      1

Environment data

7.6.0-preview.3

Binary     1.1.1                 Microsoft.PowerShell.PSResourceGet

Visuals

No response

Activity

  1. peetrike commented on May 15, 2025

    @peetrike

    also, #1467

  2. anamnavi commented on Sep 10, 2025

    @anamnavi
    Member

    Hi Thomas Nieto (@ThomasNieto) my apologies for the delay in triaging this! Looking at AnyPackage.Appx module manifest it appears you've got Appx listed under RequiredModules and under ExternalModuleDependencies. PowerShell and PSResourceGet expect a dependency module to be listed under either manifest element not both. (ie it won't detect it in both and then exclude it from RequiredModules because it was listed under ExternalModuleDependencies). So if Appx is an external dependency remove it from RequiredModules when you next publish and then install should work or ensure Appx is present.

    We've updated the docs here to be clearer about the intent of ExternalModuleDependencies

  3. peetrike commented on Sep 11, 2025

    @peetrike

    RequiredModules has 2 meanings:

    • when module is loaded, the required modules are loaded before it.
    • when module is installed, the required modules are also installed from repository

    So when module is included under ExternalModuleDependencies but not under RequiredModules, the required module is not loaded, when module is loaded.

  4. ThomasNieto commented on Sep 29, 2025

    @ThomasNieto
    ContributorAuthor

    Anam Navied (@anamnavi) can you please reopen this issue? As Meelis Nigols (@peetrike) says we need to have the module listed in RequiredModules for the PowerShell engine to import the module before loading the desired one. This is for types and other such dependencies.

    PSResourceGet should do the following.

    • If module is listed in RequiredModules and NOT ExternalModuleDependencies should install required module
    • If module is listed in RequiredModules and ExternalModuleDependencies should NOT install required module but write warning if module currently isn't present in PSModulePath
    • If module is listed in ExternalModuleDependencies should NOT install module but write warning if module currently isn't present in PSModulePath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions