Skip to content

About

MSBuild task for integrating Bun (a fast JavaScript runtime) into .NET build processes

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Scarlet.Bun

GitHub Workflow Status codecov GitHub

Bun — the fast all-in-one JavaScript runtime, bundler and package manager — for .NET, as a pinned NuGet dependency rather than something you install separately.

Bundle and minify JavaScript and TypeScript, compile Sass/SCSS, and install npm dependencies without Node.js, on Windows, Linux and macOS (x64 and ARM64).

Which package do I want?

Package Use it when
During a build NuGet You want dotnet build to bundle your assets — Blazor, Razor Class Libraries, ASP.NET Core
On the command line NuGet You want dotnet bun install / dotnet bun run build.mjs, pinned per repository

They are independent — use either, or both.

Scarlet.Bun.MSBuild — Bun during dotnet build

dotnet add package Scarlet.Bun.MSBuild
<ItemGroup>
  <BunBeforeStaticWebAssets Include="run">
    <Arguments>build.mjs</Arguments>
  </BunBeforeStaticWebAssets>
</ItemGroup>

The Bun binary comes either from a platform-specific Scarlet.Bun.Runtime.* package or from an on-demand download, whichever suits your build.

📖 Full documentation → — installation, the three runtime options, task parameters, multi-targeting, and a worked JavaScript/SCSS build script.

Scarlet.Bun.Cli — Bun on the command line

dotnet new tool-manifest
dotnet tool install Scarlet.Bun.Cli
dotnet bun run build.mjs

The tool version is the Bun version, so .config/dotnet-tools.json pins Bun alongside the rest of your tooling. Scarlet.Bun.Cli is a pointer package; installing it also pulls a matching Scarlet.Bun.Cli.* sub-package for your platform, and that one embeds the Bun binary, so it needs no network at run time.

📖 Full documentation → — installing, how it finds Bun, and the environment variables.

Available Packages

Package Contains
Scarlet.Bun.MSBuild The MSBuild task. Versioned independently.
Scarlet.Bun.Cli The dotnet bun tool. Version = the embedded Bun version.
Scarlet.Bun.Runtime.windows-x64-baseline Bun for Windows x64
Scarlet.Bun.Runtime.windows-aarch64 Bun for Windows ARM64
Scarlet.Bun.Runtime.linux-x64-baseline Bun for Linux x64
Scarlet.Bun.Runtime.linux-aarch64 Bun for Linux ARM64
Scarlet.Bun.Runtime.linux-x64-musl-baseline Bun for Linux x64, musl (Alpine)
Scarlet.Bun.Runtime.linux-aarch64-musl Bun for Linux ARM64, musl (Alpine)
Scarlet.Bun.Runtime.darwin-x64-baseline Bun for macOS x64
Scarlet.Bun.Runtime.darwin-aarch64 Bun for macOS ARM64

The Scarlet.Bun.Runtime.* packages are consumed by Scarlet.Bun.MSBuild and can also be installed directly (see its README); the CLI embeds its own Bun and does not use them. Their package version is the Bun version they contain.

Scarlet.Bun.Cli restores its own per-platform Scarlet.Bun.Cli.* sub-packages (one per RID, plus a portable .any fallback) automatically — unlike the Runtime.* packages, these are a dotnet tool implementation detail, never meant to be installed directly, so they aren't listed here.

Supported Platforms

Windows, Linux and macOS on x64 or arm64, including musl-based Linux distributions such as Alpine. Any other architecture gets an explanatory error rather than a mismatched binary — point at your own Bun with SCARLET_BUN_PATH (CLI) or BunRuntimeDirectory (MSBuild) if you need one of them.

Development

Building the Package

dotnet build

Running Tests

Unit tests:

dotnet test tests/Scarlet.Bun.MSBuild.Tests/Scarlet.Bun.MSBuild.Tests.csproj

Integration tests:

dotnet test tests/Scarlet.Bun.MSBuild.IntegrationTests/Scarlet.Bun.MSBuild.IntegrationTests.csproj

CLI tests:

dotnet test tests/Scarlet.Bun.Cli.Tests/Scarlet.Bun.Cli.Tests.csproj

All tests:

dotnet test

End-to-end scenarios pack real packages into a local feed and consume them from a temporary project. They take a workspace path, a package version and a Bun version:

tests/e2e/package-installation/verify.sh "$PWD" 1.0.0-local 1.4.2
tests/e2e/cli-tool/verify.sh            "$PWD" 1.0.0-local 1.4.2

Creating a Package

dotnet pack src/Scarlet.Bun.MSBuild/Scarlet.Bun.MSBuild.csproj

The CLI packs into ten packages at once — one per runtime identifier, a portable fallback and a top-level pointer package:

dotnet pack src/Scarlet.Bun.Cli/Scarlet.Bun.Cli.csproj

src/Scarlet.Bun.Core is a shared library used by both shipping packages. It is deliberately not published: the MSBuild package packs the assembly into its tools/ folder, and the CLI carries it in its publish output.

Requirements

  • .NET / .NET Core (no .NET Framework support)
  • Supported on Windows, Linux, and macOS

License

This project is licensed under the MIT License - see the LICENSE file for details.

Bundled Software Licenses

This project distributes official Bun executables. Bun itself is MIT licensed; its statically linked JavaScriptCore/WebKit components and other bundled libraries retain their respective licenses. See LICENSE-3RD-PARTY.txt for the notices and source links distributed with the packages, and Bun's authoritative license document for its version-specific component list and relinking instructions.

Credits

  • Built by ScarletKuro
  • Uses Bun - a fast all-in-one JavaScript runtime

Contributing

Contributions are welcome! See CONTRIBUTING.md for how to build, test, and submit a Pull Request.

About

MSBuild task for integrating Bun (a fast JavaScript runtime) into .NET build processes

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages