Skip to content

Files listed in FileList in module manifest are loaded on module load #12821

Closed

Description

Since version 6.2.0-preview.2 all the files listed in FileList are loaded when the module is loaded.

This is change in behavior caused by PR #8073 which was done to support a customer issue about loading assemblies from module folder first, before looking at GAC.

Hence, the behavior in 6.2.x and 7.0.x is different from Windows PowerShell.

I believe the current behavior is wrong and should be fixed. But, since it as release in 6.2.x and 7.0.x it will be a breaking change.

If we decide to not fix it, it might make moving from Windows PowerShell to PowerShell 7 more difficult.

I would like opinion from committee about fixing the issue in 7.1 and whether it should be back ported to 7.0.x and 6.2.x

Steps to reproduce

Load a module with managed assemblies in FileList in the psd1

$filesBefore = [System.AppDomain]::CurrentDomain.GetAssemblies()
Import-Module <>
$filesAfter = [System.AppDomain]::CurrentDomain.GetAssemblies()
 Compare-Object -ReferenceObject $filesBefore -DifferenceObject $filesAfter

Expected behavior

Files in FileList should not be loaded

Actual behavior

Files in FileList are loaded.

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.1
PSEdition                      Core
GitCommitId                    7.0.1
OS                             Microsoft Windows 10.0.19635
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Question
    Review - Committee
    on May 28, 2020
  2. vexx32 commented on May 28, 2020

    @vexx32
    Collaborator

    It's also worth noting that if the module happens to list native libraries (unmanaged compiled code) in the FileList, those loads will always fail, and the native library actually can't be loaded at all after that point. Not sure of the underlying mechanism there, but it's an extra edge case that can complicate matters. 🙂

  3. adityapatwardhan commented on May 28, 2020

    @adityapatwardhan
    MemberAuthor

    Rain Sallow (/u/ta11ow) (@vexx32) thanks for adding that.

  4. SeeminglyScience commented on May 28, 2020

    @SeeminglyScience
    Contributor

    Yes please. I've taken to just removing that field from manifests because it also throws if the assembly is already loaded.

  5. added
    WG-Engine
    on May 28, 2020
  6. SteveL-MSFT commented on Jun 3, 2020

    @SteveL-MSFT
    Member

    @PowerShell/powershell-committee reviewed this, we agreed that the desire is to have:

    1. load assemblies from module base first, then GAC
    2. not load anything from FileList restoring previous behavior
    3. fix should be backported to 7.0.x
  7. added
    Committee-Reviewed
    and removed
    Review - Committee
    on Jun 3, 2020
  8. added
    Issue-Bug
    and removed
    Issue-Question
    on Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Committee-ReviewedIssue-BugResolution-FixedWG-Engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions