- .NET 7 SDK
- and .NET 6 SDK
- and .NET 4.7.2 developer pack (Windows only)
- Node.js version 16 or later
While node-api-dotnet
supports .NET 6 or .NET Framework 4 at runtime, .NET 7 or later SDK is
required for building the AOT components.
dotnet build
While developing the source generator, set DOTNET_CLI_USE_MSBUILD_SERVER=0
to prevent MSBuild
from re-using a previously-loaded (possibly outdated) version of the source generator assembly.
(See Shut down or disable MSBuild Server.)
dotnet pack -c Release
This produces both nuget and npm packages (for the current platform only) in the out/pkg
directory.
dotnet pack
dotnet test
Some tests reference the source-generator via the local nuget package; hence it is required to run
dotnet pack
before the first time running tests, or after any changes to the generator code.
This is unavoidable because the source-generator must run with at least .NET 6, so referencing it
via a <ProjectReference>
would not work for .NET 4 testing because project references always
use the same target framework version.
Use --framework
to specify a target framework, or --filter
to run a subset of test cases:
dotnet test --framework net7.0 --filter "DisplayName~aot"
The list of test cases is automatically derived from the set of .js
files under the
Test/TestCases
directory. Within each subdirectory there, all .cs
files are compiled into one
assembly, then all .js
test files execute against the assembly.
Most test cases run twice, once for "hosted" CLR mode and once for AOT ahead-of-time compiled mode with no CLR.
With a debug build, the following environment variables trigger just-in-time debugging of the respective components:
DEBUG_NODE_API_GENERATOR
- Debug the C# source-generator when it runs during the build.DEBUG_NODE_API_RUNTIME
- Debug the .NET runtime host when it is loaded by JavaScript. (Does not apply to AOT-compiled modules.)
Also TRACE_NODE_API_HOST
causes tracing information to be printed about the the process of
loading the .NET host.
PR builds will fail if formatting does not comply with settings in .editorconfig
.
dotnet format --severity info --verbosity detailed