https://github.com/thomas3577/denohost
Run JavaScript/TypeScript from .NET using Deno
https://github.com/thomas3577/denohost
deno dotnet javascript nuget typescript
Last synced: 2 months ago
JSON representation
Run JavaScript/TypeScript from .NET using Deno
- Host: GitHub
- URL: https://github.com/thomas3577/denohost
- Owner: thomas3577
- License: mit
- Created: 2025-06-08T12:47:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-04-20T06:58:05.000Z (2 months ago)
- Last Synced: 2026-04-20T08:33:49.119Z (2 months ago)
- Topics: deno, dotnet, javascript, nuget, typescript
- Language: C#
- Homepage: https://nuget.org/packages/DenoHost.Core
- Size: 1 MB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# DenoHost




---
## About
**DenoHost** allows you to seamlessly run [Deno](https://deno.com/) 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
```bash
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.win-arm64` | Bundled Deno for Windows ARM | `win-arm64` |
| `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:
```csharp
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.
```csharp
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).
```csharp
await Deno.Execute("eval", ["console.log('hello world')"]);
```
## DenoProcess Example
For long-running processes with interactive communication:
```csharp
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](./LICENSE).
## Security Policy
See [SECURITY.md](./SECURITY.md) for how to report vulnerabilities.
## Links
- [deno.com](https://deno.com/)
- [NuGet Gallery](https://www.nuget.org/packages?q=DenoHost)