Title: It's Really Hard To Package Native Libraries for PowerShell Modules · Issue #8861 · PowerShell/PowerShell · GitHub
Open Graph Title: It's Really Hard To Package Native Libraries for PowerShell Modules · Issue #8861 · PowerShell/PowerShell
X Title: It's Really Hard To Package Native Libraries for PowerShell Modules · Issue #8861 · PowerShell/PowerShell
Description: OK, so... this is an issue that's been around for a long time, I'm sure. I've not really had reason to hit it before. And now I have. Scenario I'm trying to package a module with a dependency that does p/invoking via native runtime libra...
Open Graph Description: OK, so... this is an issue that's been around for a long time, I'm sure. I've not really had reason to hit it before. And now I have. Scenario I'm trying to package a module with a dependency that ...
X Description: OK, so... this is an issue that's been around for a long time, I'm sure. I've not really had reason to hit it before. And now I have. Scenario I'm trying to package a module with a ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/8861
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"It's Really Hard To Package Native Libraries for PowerShell Modules","articleBody":"OK, so... this is an issue that's been around for a long time, I'm sure. I've not really had reason to hit it before. And now I have.\r\n\r\n# Scenario\r\n\r\nI'm trying to package a module with a dependency that does p/invoking via native runtime libraries. The library is [SkiaSharp](/mono/SkiaSharp). This library cannot be used without native runtimes.\r\n\r\nI'd like to be able to handle native runtimes _correctly_ from a compiled PowerShell cmdlet / module.\r\n\r\n# Problem\r\n\r\nThe issue then becomes that these native runtimes are different on each platform. Each platform expects that the libraries will be in the same folder as the SkiaSharp.dll. This can't be done for every platform at once, as several of the platform-specific libraries have the same name. \r\n\r\nThe folder structure after running `dotnet publish` looks like this:\r\n\r\n\r\n\r\nIgnoring the `tizen` runtimes (I think they're for Android or something? not sure), a few of the libraries have the same filenames, namely the Windows libraries for the two architectures. A _temporary_ workaround is to put as much as possible in the same folder and ignore that x86 Windows still exists.\r\n\r\n# Attempted Solutions\r\n\r\nWe have tried to work around the problem by selectively importing the native libraries, but this is entirely impossible with PowerShell as they throw `Bad IL format` errors. We have tried:\r\n\r\n1. `Import-Module .\\bin\\Debug\\netstandard2.0\\publish\\runtimes\\\u003cplatform>\\native\\\u003cruntime_file>`\r\n2. `Add-Type -Path .\\bin\\Debug\\netstandard2.0\\publish\\runtimes\\\u003cplatform>\\native\\\u003cruntime_file>`\r\n3. `[System.Reflection.Assembly]::LoadFile((Resolve-Path \".\\bin\\Debug\\netstandard2.0\\publish\\runtimes\\\u003cplatform>\\native\\\u003cruntime_file>\"))`\r\n\r\n# Possible Solutions\r\n\r\n* Ability to specify dependencies such as these by relative path in a PSD1 on a per-platform basis, which is respected with `Import-Module` and loaded correctly.\r\n* Some kind of handling in PowerShellGet for native runtimes on a per-platform basis? Possibly handled via NuGet in terms of pulling down the exact runtime required on a specific platform.\r\n\r\nThere's probably a neater solution I'm missing, feel free to add any suggestions.\r\n\r\n# Files\r\n\r\nSource & module files for reference, if you should like to attempt anything with them:\r\nhttps://github.com/vexx32/PSWordCloud/tree/Cmdlet/PSWordCloud\r\n\r\n# Running PSWordCloud\r\nTo use:\r\n1. Publish the source files for this module with `dotnet publish`\r\n2. Import the PSM1 file in the linked folder with `Import-Module`\r\n3. Attempt to pipe some text into `New-WordCloud -Path .\\test.svg`\r\n\r\nThis **will** work on Windows thanks to the PSM1 manually modifying $env:Path to add all the native runtime folders. This solution is _terribly_ messy and absolutely makes a right royal mess of $env:Path for anyone importing the module. I would like to avoid this.\r\n\r\nIt _attempts_ to do similar on Mac OS and Linux, but in these cases it seems the path for native runtime libraries isn't searched correctly. The only currently available workaround is manually copying these libraries to the same folder as `SkiaSharp.dll` which is... less than great. \r\n\r\n/cc @TylerLeonhardt @daxian-dbw @SteveL-MSFT ","author":{"url":"https://github.com/vexx32","@type":"Person","name":"vexx32"},"datePublished":"2019-02-10T23:15:58Z","url":"https://github.com/PowerShell/PowerShell/issues/8861"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:420d5236-2f93-ecde-a091-0ca7596997ae |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C7B8:3A960E:1E1AB7:28625E:6AFD4493 |
| html-safe-nonce | 05dc143fb8584ea8fb12fccfb352ef3bfc180e899d841d0d8f6f49d2168f457e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDN0I4OjNBOTYwRToxRTFBQjc6Mjg2MjVFOjZBRkQ0NDkzIiwidmlzaXRvcl9pZCI6IjcyMjk1MjM1NzEzMDU2OTQzNTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e1859fd755a36ae0c4b680fc4a31fa2305a40677b3de1b161ddd35e0d3bb1136 |
| hovercard-subject-tag | issue:408595389 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/8861/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2a65cd6205cede8531a63911fe0aed6dc2f02f84404623d7e2935f8914bbb6ca/PowerShell/PowerShell/issues/8861 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2a65cd6205cede8531a63911fe0aed6dc2f02f84404623d7e2935f8914bbb6ca/PowerShell/PowerShell/issues/8861 |
| og:image:alt | OK, so... this is an issue that's been around for a long time, I'm sure. I've not really had reason to hit it before. And now I have. Scenario I'm trying to package a module with a dependency that ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vexx32 |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width