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

Build libnode and publish nuget packages #107

Open
jasongin opened this issue Apr 21, 2023 · 11 comments
Open

Build libnode and publish nuget packages #107

jasongin opened this issue Apr 21, 2023 · 11 comments
Assignees
Labels
Milestone

Comments

@jasongin
Copy link
Member

jasongin commented Apr 21, 2023

For embedding Node.js, we need to build libnode binaries for each supported platform, and publish the binaries as native nuget packages.

Until the Node API embedding PR is merged, we'll need to build from a fork. And, it may require manually merging the PR changes into the target version of Node.js. I did that for Node.js v19.9 and v20.0 already:
https://github.com/jasongin/nodejs/tree/napi-libnode-v19.9.0
https://github.com/jasongin/nodejs/tree/napi-libnode-v20.0.0

(I tried to backport to v18, but the PR changes depended on significant updates in v19.)

Edit: Instructions for building libnode are at https://microsoft.github.io/node-api-dotnet/scenarios/dotnet-js.html

@jasongin jasongin converted this from a draft issue Apr 21, 2023
@jasongin jasongin added the build label Apr 21, 2023
@vmoroz vmoroz self-assigned this Apr 21, 2023
@vmoroz
Copy link
Member

vmoroz commented Apr 21, 2023

I am going to work on implementing an ADO pipeline to publish libnode as a Nuget package.

@vmoroz vmoroz moved this from 🔖 Ready to 🏗 In progress in node-api-dotnet tasks Apr 21, 2023
@ShortDevelopment
Copy link

Are there already nuget packages for libnode or can I download the binaries somewhere?

@jasongin
Copy link
Member Author

Not yet. @vmoroz was working on that but got busy with other priorities.

@jasongin
Copy link
Member Author

Update: This is the latest known good branch for building a libnode that works with this project:
https://github.com/jasongin/nodejs/tree/napi-libnode-v20.9.0

@239573049
Copy link

So far there seems to be no progress?

@glacasa
Copy link

glacasa commented Apr 14, 2024

The README says we can contact you to get a copy of libnode.
But here we only have a link to the source, and I have no idea how to build it

Could you put it in a public Onedrive somewhere ?
I understand the pipeline to publish nuget package is not ready, but if we could just have a downloadable version (even if not updated regularly), it would allow us to test the code

Thanks

@jasongin
Copy link
Member Author

@vmoroz has been making some progress on this recently, but it's not ready yet.

Sorry I cannot publish an unsigned binary built on my dev machine in any official location such as a GH release. But it's not too hard to build your own.

Build instructions:

  1. Install prerequisites documented at https://github.com/nodejs/node/blob/main/BUILDING.md#building-nodejs-on-supported-platforms. (On Windows this is basically Python 3 and either VS 2022 or the C++ build tools.)

  2. Clone the napi-libnode repo/branch:

mkdir libnode
cd libnode
git clone https://github.com/jasongin/nodejs -b napi-libnode-v20.9.0 --single-branch .
  1. Build in shared-library mode.
    Windows: .\vcbuild.bat x64 release dll openssl-no-asm
    Mac/Linux: ./configure --shared; make -j4
    The build may take an hour or more depending on the speed of your system.

@rocklau
Copy link

rocklau commented Jul 16, 2024

It is recommended to put this instruction in the readme

@jasongin
Copy link
Member Author

The info on the new docs site published a few days ago:
https://microsoft.github.io/node-api-dotnet/scenarios/dotnet-js.html

I haven't updated the main README yet to link to that site, but I will soon.

@delneg
Copy link

delneg commented Jul 21, 2024

@glacasa @rocklau @jasongin
We've built a reproducible setup for libnode builds, currently supporting linux-x64
https://github.com/SigmaGmbH/dotnet-libnode-docker/
You can grab and use it like so:

FROM ghcr.io/sigmagmbh/dotnet-libnode-docker:latest AS libnode
FROM ubuntu/dotnet-aspnet:8.0 AS final
COPY --from=libnode lib/libnode.so.115 /app/js/libnode.so.115
ENTRYPOINT ["dotnet", "/app/TestProject.dll"]

Assuming the app was built and published to /app in previous steps, and will do

string baseDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "js");
string libnodePath = Path.Combine(baseDir, "libnode.so.115");
var nodejsPlatform = new NodejsPlatform(libnodePath);

@rocklau
Copy link

rocklau commented Aug 2, 2024

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🏗 In progress
Development

No branches or pull requests

7 participants