Skip to content

"Dependency on Native Libraries" adds extra file extensions #19277

@ili101

Description

@ili101

Update:

So valid paths currently are:
Linux: "./linux-x64/SQLite.Interop.dll.so"
Windows: ".\win-x64\SQLite.Interop.dll.dll"
Windows: ".\x64\SQLite.Interop.dll"
OSX = "./osx-x64/SQLite.Interop.dll.dylib"

Is this by design?
Shouldn't it just leave the file names as is without adding the extra extensions like "foo.dll.dll"?

This should probably be noted in documentation.
Also documentation example RIDs can be updated as mentioned in #19277 (comment)

Original

Prerequisites

Steps to reproduce

I don't understand how to use this or it doesn't work?
https://learn.microsoft.com/en-us/powershell/scripting/dev-cross-plat/writing-portable-modules?view=powershell-7.3#dependency-on-native-libraries

Example module https://github.com/ili101/DependencyonNativeLibraries/tree/master/TestDependencies
Using manifest "RequiredAssemblies" or Add-Type in psm1 to load the dll then using the assembly by executing Test-Dependencies results in error:
"Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies." ... "No such file or directory"

When copying the the OS specific dll file to the same folder it works in Windows, Linux and macOS.
So why is this auto detecting feature of PS 7 not working here?

Expected behavior

The correct dependency native dll is loaded.

Actual behavior

It looks for the dependency native dll in the same folder as the main dll and fail to load.
On windows it also work if the dependent dll placed in "x64" folder.

You can see all OSs vs file location results in the GitHub Action https://github.com/ili101/DependencyonNativeLibraries/actions/runs/4328219121

Error details

"Exception calling ".ctor" with "1" argument(s): "Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libSQLite.Interop.dll: cannot open shared object file: No such file or directory""

Environment data

Dlls were generated by https://github.com/ili101/DependencyonNativeLibraries/tree/master/HelloWorld

GitHub Actions uses:
PSVersion             : 7.2.9

Also tested on:
Name                           Value
----                           -----
PSVersion                      7.3.3
PSEdition                      Core
GitCommitId                    7.3.3
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueNeeds-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions