Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerShell 7 Native Host #3

Open
awakecoding opened this issue Jun 8, 2021 · 0 comments
Open

PowerShell 7 Native Host #3

awakecoding opened this issue Jun 8, 2021 · 0 comments

Comments

@awakecoding
Copy link

Hi! I just found out about your project and wanted to let you know I've been working on something similar on my side meant to load PowerShell 7 entirely at runtime from its installation path. I finished my initial proof-of-concept code in C, after which I intend to port it to Rust. Your project is definitely much more advanced on the Rust side, but you may be interested in taking some bits and pieces from the dynamic loading technique that eliminates the need for statically linking anything from .NET.

Here are the relevant issues:
PowerShell/PowerShell#14652
PowerShell/PowerShell#14641
dotnet/runtime#46652

And the reference code I have so far:
https://github.com/awakecoding/pwsh-native-host
https://github.com/awakecoding/pwsh-host-rs

Since PowerShell 7 ships a full copy of .NET 5, my project aims at detecting PowerShell and then loading it. Nothing really prevents loading another .NET 5 runtime from another location, and re-implementing the nethost static library that exports a single function to facilitate detection. My intent is really to make PowerShell (or .NET 5) fully usable as a library without installing additional files.

You will notice the related issues are all about adding a single helper function to make it possible to load an assembly file in memory. Rust makes it quite easy to embed files, but for the C code I wrote a script to generate a static array. PowerShell 7.2-preview6 now includes "LoadAssemblyFromNativeMemory" but this function could be provided by a separate DLL and ported to anything, really, if you can afford to ship an additional DLL with your program.

Let me know if some of the things I've done on my side could interest you for this project. Your Rust code is much more advanced than my current C code I've barely begun porting to Rust. I'll be working on this for the next week or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant