5
5
- _ and_ [ .NET 6 SDK] ( https://dotnet.microsoft.com/en-us/download/dotnet/6.0 )
6
6
- _ and_ [ .NET 4.7.2 developer pack] ( https://dotnet.microsoft.com/en-us/download/dotnet-framework/net472 )
7
7
(Windows only)
8
- - [ Node.js] ( https://nodejs.org/ ) version 16 or later
8
+ - [ Node.js] ( https://nodejs.org/ ) version 18 or later
9
9
10
10
While ` node-api-dotnet ` supports .NET 6 or .NET Framework 4 at runtime, .NET 8 or later SDK is
11
11
required for building the AOT components.
@@ -21,10 +21,11 @@ from re-using a previously-loaded (possibly outdated) version of the source gene
21
21
22
22
## Build Packages
23
23
``` bash
24
- dotnet pack -c Release
24
+ dotnet pack
25
25
```
26
26
This 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.
28
29
29
30
## Test
30
31
``` bash
@@ -50,16 +51,60 @@ assembly, then all `.js` test files execute against the assembly.
50
51
Most test cases run twice, once for "hosted" CLR mode and once for AOT ahead-of-time compiled mode
51
52
with no CLR.
52
53
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
+
53
91
## Debugging
54
92
With a debug build, the following environment variables trigger just-in-time debugging of the
55
93
respective components:
56
94
- ` 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.
58
96
- ` NODE_API_DEBUG_RUNTIME=1 ` - Debug the .NET runtime host when it is loaded by JavaScript. (Does
59
97
not apply to AOT-compiled modules.)
98
+
60
99
Setting 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.)
63
108
64
109
## Tracing
65
110
The 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
74
119
dotnet format --severity info --verbosity detailed
75
120
```
76
121
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
+
77
126
## Roadmap
127
+ We track major feature work on the project board:
78
128
[ node-api-dotnet tasks] ( https://github.com/users/jasongin/projects/1/views/1 )
0 commit comments