Microsoft Replaces C++ Node.js Addons with C# and .NET Native AOT in C# Dev Kit

By
<h2>Breaking: C# Dev Kit Eliminates Python Dependency for Native Addons</h2> <p>Microsoft's C# Dev Kit team has overhauled their Node.js native addon build process, replacing C++ modules with C# code compiled via <strong>.NET Native AOT</strong>. The move eliminates the need for Python and node-gyp, a long-standing pain point for developers.</p><figure style="margin:20px 0"><img src="https://devblogs.microsoft.com/dotnet/wp-content/uploads/sites/10/2026/04/writing-nodejs-addons.webp" alt="Microsoft Replaces C++ Node.js Addons with C# and .NET Native AOT in C# Dev Kit" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px">Source: devblogs.microsoft.com</figcaption></figure> <p><strong>&ldquo;We already have the .NET SDK installed, so using C# and Native AOT to streamline our engineering systems was a natural step,&rdquo;</strong> said a Microsoft engineer familiar with the project. &ldquo;This removes an entire class of setup friction for contributors and CI pipelines.&rdquo;</p> <h2 id="background">Background: The old way</h2> <p>Historically, the C# Dev Kit extension used <strong>native Node.js addons written in C++</strong> for platform-specific tasks like reading the Windows Registry. These addons were compiled with <em>node-gyp</em>, which requires an old version of Python on every developer machine.</p> <p>For a team focused on .NET tooling, that Python dependency added significant overhead. New contributors had to install tools they&rsquo;d never use directly, and CI pipelines spent extra cycles provisioning and maintaining Python environments.</p> <h2 id="how-it-works">How .NET Native AOT simplifies the process</h2> <p>Node.js native addons are shared libraries (<code>.dll</code>, <code>.so</code>, or <code>.dylib</code>) that export a specific entry point called <code>napi_register_module_v1</code>. The N-API (Node-API) interface is language-agnostic&mdash;it only requires the library to export the right symbols.</p> <p>.NET Native AOT can produce such shared libraries from C# code. The new addon project file is minimal:</p> <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt; &lt;PropertyGroup&gt; &lt;TargetFramework&gt;net10.0&lt;/TargetFramework&gt; &lt;PublishAot&gt;true&lt;/PublishAot&gt; &lt;AllowUnsafeBlocks&gt;true&lt;/AllowUnsafeBlocks&gt; &lt;/PropertyGroup&gt; &lt;/Project&gt; </code></pre> <p>The <code>PublishAot</code> flag tells the SDK to emit a shared library, while <code>AllowUnsafeBlocks</code> permits the function pointers and fixed buffers that N-API interop requires. The entry point is defined with <code>[UnmanagedCallersOnly]</code> attribute.</p><figure style="margin:20px 0"><img src="https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png" alt="Microsoft Replaces C++ Node.js Addons with C# and .NET Native AOT in C# Dev Kit" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px">Source: devblogs.microsoft.com</figcaption></figure> <h2 id="what-this-means">What This Means</h2> <p>Developers using the C# Dev Kit will no longer need to install Python or manage a separate C++ build chain. This reduces setup time for new contributors and simplifies CI/CD configurations.</p> <p>More broadly, this demonstrates that .NET Native AOT can serve as a viable alternative to C++ for building Node.js native addons. Teams already invested in the .NET ecosystem can leverage their existing skills and tooling without sacrificing performance.</p> <p><strong>&ldquo;This is a win for developer productivity,&rdquo;</strong> the engineer added. &ldquo;We get the same native performance with fewer dependencies and a unified build pipeline.&rdquo;</p> <h2 id="look-ahead">Looking ahead</h2> <p>Microsoft plans to continue refining the approach and is evaluating whether to open-source the pattern for other teams to adopt. The move could encourage broader adoption of <em>.NET Native AOT</em> for cross-platform native extensions in the Node.js ecosystem.</p> <p>For now, the C# Dev Kit team recommends that .NET shops explore <a href="https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/">Native AOT documentation</a> as a starting point for similar migrations.</p>

Related Articles