Skip to content

Assemblies listed in FileList Module Manifest Property are being Processed. #13487

@tomohulk

Description

@tomohulk

Steps to reproduce

I have a WinSCP PowerShell Module Wrapper, and I was implementing some functionality to load one WinSCPnet.dll if it is PowerShell core, and a different one if it is PowerShell desktop. And I kept getting errors stating that the assembly of the same name was already loaded.

Turns out, I had both of the assemblies listed in the Module Manifest FileList property, after removing them from there, the logic to add the correct assembly works fine. Per this link, that property should be for inventory only, and should not process the files in the value: https://docs.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7#module-manifest-elements

# Assembly loading logic from  WinSCP.psm1
$moduleRoot = Split-Path -Path $MyInvocation.MyCommand.Path
switch ($PSVersionTable.PSEdition) {
    "Core" {
        #Add-Type -Path "${moduleRoot}\lib\netstandard2.0\WinSCPnet.dll"
        add-type -path ./Documents/github/WinSCP/WinSCP/lib/netstandard2.0/WinSCPnet.dll
        break;
    }

    "Desktop" {
        Add-Type -Path "${moduleRoot}\lib\net40\WinSCPnet.dll"
        break;
    }

    default {
        Write-Error -Message "Failed to find a compatiable WinSCP Assembly."
        exit
    }
}

When the FileList property in the manifest has those files listed in the value, I get the "Assembly with the same name is already loaded" error
image
image

if I remove the .dll values from that list, the logic works fine and the proper dll is loaded.

Expected behavior

No processing of the files in the FileList module manifest property value.

Actual behavior

Im not sure in what way, but he files are being executed or processed.

Environment data

PS /Users/thomas> $psversiontable

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Darwin 20.0.0 Darwin Kernel Version 20.0.0: Thu…
Platform                       Unix
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

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aReview - MaintainerThe PR/issue needs a review from the PowerShell repo Maintainers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions