Skip to content

thomas3577/DenoHost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DenoHost

Build Coverage NuGet License: MIT


About

DenoHost allows you to seamlessly run Deno scripts or inline JavaScript/TypeScript code within your .NET applications.
It bundles platform-specific Deno executables as separate NuGet packages and provides a simple, consistent API for execution.


Features

  • Modular runtime packages (per RID)
  • Clean .NET API with async execution
  • Testable with xUnit
  • Packaged for NuGet (multi-target)
  • Linux, Windows, macOS support

NuGet Packages

dotnet add package DenoHost.Core
Package Description Platforms
DenoHost.Core Core execution logic (API) all
DenoHost.Runtime.win-x64 Bundled Deno for Windows win-x64
DenoHost.Runtime.linux-x64 Deno for Linux linux-x64
DenoHost.Runtime.linux-arm64 Deno for ARM Linux linux-arm64
DenoHost.Runtime.osx-x64 Deno for macOS Intel osx-x64
DenoHost.Runtime.osx-arm64 Deno for macOS Apple Silicon osx-arm64

Deno.Execute Example

For simple script execution with immediate results:

using DenoHost.Core;

var options = new DenoExecuteBaseOptions { WorkingDirectory = "./scripts" };
string[] args = ["run", "app.ts"];

await Deno.Execute(options, args);

Cancellation

You can cancel execution via a CancellationToken. Cancellation throws an OperationCanceledException and terminates the underlying Deno process.

using DenoHost.Core;

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));

var options = new DenoExecuteBaseOptions { WorkingDirectory = "./scripts" };
await Deno.Execute(options, ["run", "long-running.ts"], cts.Token);

Arguments and quoting

DenoHost passes arguments via ProcessStartInfo.ArgumentList. Pass each argument as its own string (avoid adding shell-style quotes inside argument strings).

await Deno.Execute("eval", ["console.log('hello world')"]);

DenoProcess Example

For long-running processes with interactive communication:

using DenoHost.Core;

// Create a managed Deno process
using var denoProcess = new DenoProcess(
  command: "run",
  args: ["--allow-read", "server.ts"],
  workingDirectory: "./scripts"
);

// Start the process
await denoProcess.StartAsync();

// Send input to the process
await denoProcess.SendInputAsync("hello");

// Stop gracefully when done
await denoProcess.StopAsync();

Requirements

  • .NET 9.0+
  • Deno version is bundled per RID via GitHub Releases
  • No need to install Deno globally

Feedback

If you're using DenoHost in a real project, I'd love to hear about it.

License

This project is licensed under the MIT License.

Security Policy

See SECURITY.md for how to report vulnerabilities.

Links

About

Run JavaScript/TypeScript from .NET using Deno

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •