Skip to content

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

@adityapatwardhan

Description

@adityapatwardhan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Committee-ReviewedPS-Committee has reviewed this and made a decisionIssue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions