Open jasongin opened 1 year ago
I am going to work on implementing an ADO pipeline to publish libnode as a Nuget package.
Are there already nuget packages for libnode or can I download the binaries somewhere?
Not yet. @vmoroz was working on that but got busy with other priorities.
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
So far there seems to be no progress?
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
@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:
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.)
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 .
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.
It is recommended to put this instruction in the readme
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.
@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);
Thanks a lot.
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