55 - _ and_ [ .NET 6 SDK] ( https://dotnet.microsoft.com/en-us/download/dotnet/6.0 )
66 - _ and_ [ .NET 4.7.2 developer pack] ( https://dotnet.microsoft.com/en-us/download/dotnet-framework/net472 )
77 (Windows only)
8- - [ Node.js] ( https://nodejs.org/ ) version 16 or later
8+ - [ Node.js] ( https://nodejs.org/ ) version 18 or later
99
1010While ` node-api-dotnet ` supports .NET 6 or .NET Framework 4 at runtime, .NET 8 or later SDK is
1111required for building the AOT components.
@@ -21,10 +21,11 @@ from re-using a previously-loaded (possibly outdated) version of the source gene
2121
2222## Build Packages
2323``` bash
24- dotnet pack -c Release
24+ dotnet pack
2525```
2626This produces both nuget and npm packages (for the current platform only) in the ` out/pkg `
27- directory.
27+ directory. It uses ` Debug ` configuration by default, which is slower but allows for
28+ [ debugging] ( #debugging ) . Append ` -c Relase ` to change the configuration.
2829
2930## Test
3031``` bash
@@ -50,16 +51,60 @@ assembly, then all `.js` test files execute against the assembly.
5051Most test cases run twice, once for "hosted" CLR mode and once for AOT ahead-of-time compiled mode
5152with no CLR.
5253
54+ ### Test a Private Build in another project
55+ A project typically consumes the ` Microsoft.JavaScript.NodeApi ` packages from ` nuget.org ` . Use these
56+ steps to set up a project to use a local build of the packages instead:
57+ 1 . [ Build nuget packages] ( #build-packages ) with ` dotnet pack ` .
58+ 2 . Note the version of the packages produced. If building from branch other than ` main ` the
59+ package version may include a git commit hash.
60+ 3 . Add the package output directory to ` <packageSources> ` in your project's ` NuGet.config ` file,
61+ before the ` nuget.org ` package source. It should look like this. (Replace
62+ ` /path/to-/node-api-dotnet ` with the correct relative or absolute path on your system.)
63+ ``` xml
64+ <?xml version =" 1.0" encoding =" utf-8" ?>
65+ <configuration >
66+ <packageSources >
67+ <clear />
68+ <add key =" local" value =" /path/to/node-api-dotnet/out/pkg" />
69+ <add key =" nuget.org" value =" https://api.nuget.org/v3/index.json" />
70+ </packageSources >
71+ <disabledPackageSources >
72+ <clear />
73+ </disabledPackageSources >
74+ </configuration >
75+ ```
76+ 4 . In your ` .csproj ` or ` Directory.Packages.props ` file, update ` <PackageReference> ` elements to
77+ reference the version of the packages that you built locally. Include the git commit hash suffix,
78+ if applicable. For example:
79+ ``` xml
80+ <ItemGroup >
81+ <PackageReference Include =" Microsoft.JavaScript.NodeApi" Version =" 0.4.31-g424705b2aa" />
82+ <PackageReference Include =" Microsoft.JavaScript.NodeApi.Generator" Version =" 0.4.31-g424705b2aa" />
83+ </ItemGroup >
84+ ```
85+ 5 . Stop the .NET build server to ensure it doesn't continue using a previous version of the
86+ generator assembly:
87+ ``` bash
88+ dotnet build-server shutdown
89+ ```
90+
5391## Debugging
5492With a debug build, the following environment variables trigger just-in-time debugging of the
5593respective components:
5694 - ` NODE_API_DEBUG_GENERATOR=1 ` - Debug the C# source-generator or TS type-definitions generator
57- when they runs during the build.
95+ when they run during the build.
5896 - ` NODE_API_DEBUG_RUNTIME=1 ` - Debug the .NET runtime host when it is loaded by JavaScript. (Does
5997 not apply to AOT-compiled modules.)
98+
6099Setting either of these variables to ` 1 ` causes the program to print a message to the console
61- at startup and wait for a debugger to attach. Set to the string ` vs ` to use the VS JIT
62- Debug dialog instead (requires Windows and a Visual Studio installation).
100+ at startup and wait (with 20s countdown) for a debugger to attach:
101+ ```
102+ ###################### DEBUG ######################
103+ Process "node" (21864) is waiting for debugger.
104+ Press any key to continue without debugging... (20)
105+ ```
106+ Set to the string ` vs ` to use the VS JIT Debug dialog instead. (Requires Windows and a Visual Studio
107+ installation.)
63108
64109## Tracing
65110The following environment variables trigger verbose tracing to the console:
@@ -74,5 +119,10 @@ PR builds will fail if formatting does not comply with settings in `.editorconfi
74119dotnet format --severity info --verbosity detailed
75120```
76121
122+ ## Benchmarks
123+ There are a lot of micro-benchmarks to measure low-level .NET/JS interop operations. See
124+ [ bench/README.md] ( ./bench/README.md ) for details.
125+
77126## Roadmap
127+ We track major feature work on the project board:
78128[ node-api-dotnet tasks] ( https://github.com/users/jasongin/projects/1/views/1 )
0 commit comments