Skip to content

Loading Native Binaries in cross platform modules #6642

Description

When taking dependencies (like ASP.NET Core), it may be required to load a native binary. This requires determining the correct runtime identifier and loading the correct binary at runtime.

image

Determine the RID:
image

Load the binary:
image

It would be great to either have some sort of capability in PowerShell to help alleviate this issue.

Another recommended approach was to update Install-Module to behave more like NuGet where it will only install the binaries required for a particular operating system or platform.

Activity

  1. iSazonov commented on Apr 13, 2018

    @iSazonov
    Collaborator

    You could use .Net Core APIs and Add-Type cmdlet if you are talking about scripts.

  2. added
    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif
    on Apr 13, 2018
  3. Jaykul commented on Jul 6, 2018

    @Jaykul
    Contributor

    This is related to #3091 XPLAT: RequiredAssemblies must automatically consider lib\framework

  4. iSazonov commented on Jul 7, 2018

    @iSazonov
    Collaborator

    Until now, we do not have unified support in .Net Core for argument conversions. Without this, it makes no sense to do something here. Even the simplest type int can be implemented differently on different platforms. It can even have an inverted order of bytes. This is even more unpredictable for struct-s.

  5. Jaykul commented on Oct 28, 2018

    @Jaykul
    Contributor

    Ilya (@iSazonov) what does that have to do with anything? This is not an issue of types or unified anything.

    We need PowerShell to do at run time the same thing that nuget does at compile time:

    1. Developer ships set of runtime-specific folders with assemblies in them
    2. Developer documents the RootModule or RequiredAssembly
    3. User just Imports the module
    4. PowerShell picks the right folder, because it knows what OS/framework/runtime it is.

    Note that this is NOT only a linux vs Windows vs mac problem. PowerShell Core on Windows requires different assemblies than Windows PowerShell, even for formerly simple things shipped by Microsoft (e.g. for System.Drawing.Common).

  6. SteveL-MSFT commented on Oct 29, 2018

    @SteveL-MSFT
    Member

    Off the top of my head (aka not fully thought through), it seems we can try loading from a runtimes folder in the module base otherwise fallback to looking in the module base folder (and finally the GAC where appropriate). This would make it compatible with existing modules and Windows PowerShell.

  7. iSazonov commented on Oct 29, 2018

    @iSazonov
    Collaborator

    My strong thoughts is that it is not PowerShell Core engine issue. The issue exists in all portable projects using p/invokes. And it should be addressed in C# language (enhance DllImport and marshalling because DllImport and marshalling came form Windows and is limited on Unix-es) and CoreFX/CoreCLR engine. Until that we can use workarounds like ones from initial post of the Issue.

  8. Jaykul commented on Oct 30, 2018

    @Jaykul
    Contributor

    Actually, other portable projects (like PowerShell itself) using p/invoke do not have this problem, but that's because they only package the right binaries for the right platform, and have separate packages...

    Despite that, I think Ilya (@iSazonov) is probably right -- I would be happy to amend my earlier post to say that PowerShellGet should do it at install time, instead of PowerShell doing it at runtime. Then it's just a packaging problem: #PowerShellGet/273

  9. iSazonov commented on Oct 30, 2018

    @iSazonov
    Collaborator

    I intermediately set Resolution-External label. I think we can close the issue. But feel free to continue the discussion in any way..

  10. SteveL-MSFT commented on Oct 30, 2018

    @SteveL-MSFT
    Member

    I would suggest continuing discussion in the PSGet issue.

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

    Area-PowerShellGetspecific to PowerShellGet moduleIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-ExternalThe issue is caused by external component(s).WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions