Js2IL.Core 0.9.6

dotnet add package Js2IL.Core --version 0.9.6
                    
NuGet\Install-Package Js2IL.Core -Version 0.9.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Js2IL.Core" Version="0.9.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Js2IL.Core" Version="0.9.6" />
                    
Directory.Packages.props
<PackageReference Include="Js2IL.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Js2IL.Core --version 0.9.6
                    
#r "nuget: Js2IL.Core, 0.9.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Js2IL.Core@0.9.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Js2IL.Core&version=0.9.6
                    
Install as a Cake Addin
#tool nuget:?package=Js2IL.Core&version=0.9.6
                    
Install as a Cake Tool

Js2IL.Core

Js2IL.Core is the referenceable NuGet package for the reusable js2il compiler library.

It ships the Js2IL.Compiler.dll assembly and compiler dependencies so custom .NET tools, build tasks, test harnesses, and hosts can compile JavaScript to .NET assemblies without shelling out to the js2il CLI tool.

The primary entry points are the existing Js2IL.Compiler, Js2IL.CompilerOptions, and Js2IL.CompilerServices types in the Js2IL namespace.

Which package should I use?

  • Js2IL.Core
    • Use this when you want to embed the compiler directly in your own .NET code.
  • Js2IL.SDK
    • Use this when your project should compile JavaScript during dotnet build.
  • js2il
    • Use this when you want the command-line tool for manual or ad-hoc compilation.
  • Js2IL.Runtime
    • Use this when your host application needs the runtime support library used by generated assemblies.

Official releases publish Js2IL.Runtime, js2il, Js2IL.Core, and Js2IL.SDK together at the same version. Keep the versions aligned when you mix them in one workflow.

Install

<ItemGroup>
  <PackageReference Include="Js2IL.Core" Version="VERSION" />
</ItemGroup>

Basic usage

using Js2IL;
using Microsoft.Extensions.DependencyInjection;

var options = new CompilerOptions
{
    OutputDirectory = @"C:\code\out",
    Verbose = true,
    EmitPdb = true
};

using var services = CompilerServices.BuildServiceProvider(options);
var compiler = services.GetRequiredService<Compiler>();

if (!compiler.Compile(@"C:\code\sample.js"))
{
    throw new InvalidOperationException("Compilation failed.");
}

Compiler.Compile(...) returns true on success and writes the generated files to CompilerOptions.OutputDirectory. If OutputDirectory is omitted, JS2IL writes next to the input file.

What gets generated?

Given an input like C:\code\sample.js, JS2IL emits the following into the output directory:

  • sample.dll
    • The compiled .NET assembly for your JavaScript.
  • sample.runtimeconfig.json
    • Runtime configuration for the dotnet host.
  • JavaScriptRuntime.dll (+ optional JavaScriptRuntime.pdb)
    • The runtime support library required to execute the generated assembly.

Useful options

  • OutputDirectory
    • Where generated files are written. If omitted, output is written next to the input file.
  • Verbose
    • Enables compiler progress logging.
  • DiagnosticFilePath
    • Writes compiler diagnostics to a text file.
  • AnalyzeUnused
    • Reports unused functions, properties, and variables.
  • StrictMode
    • Controls how missing "use strict" directive prologues are reported.
  • EmitPdb
    • Emits Portable PDB symbols next to the generated assembly.
  • GenerateModuleExportContracts
    • Emits typed CommonJS export contracts for .NET hosting scenarios.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Js2IL.Core:

Package Downloads
Js2IL.SDK

MSBuild SDK package for compiling JavaScript sources into .NET assemblies during dotnet build.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.6 36 4/2/2026
0.9.5 105 3/29/2026
0.9.3 123 3/15/2026
0.9.2 117 3/14/2026