HUB
Sign inSign up
csrun logo

codebeltnet/csrun

By codebeltnet

•Updated 4 days ago

Run C# console snippets and xUnit v3 tests in disposable .NET 10/11 SDK containers.

Image
Languages & frameworks
Developer tools
0

2.2K

codebeltnet/csrun repository overview

⁠csrun — Run C# without the ceremony

Run C# console applications and genuine xUnit v3 tests directly inside disposable .NET SDK containers.

csrun⁠ provides a lightweight execution environment for C# examples, experiments, documentation samples, and automated tests.

Supply a JSON manifest through standard input, and csrun handles source preparation, dependency resolution, compilation, execution, and cleanup.

No local .NET SDK, PowerShell installation, IDE, or project scaffolding required. Just Docker.

⁠Quick start

The following examples use PowerShell syntax.

Execute a C# console application:

'{"schemaVersion":1,"mode":"console","framework":"net10.0","source":"Console.WriteLine(42);"}' | docker run --rm -i codebeltnet/csrun:10

Output:

42

Execute a genuine xUnit v3 test:

'{"schemaVersion":1,"mode":"test","framework":"net10.0","source":"using Xunit; public class SmokeTest { [Fact] public void Pass() => Assert.True(true); }"}' | docker run --rm -i codebeltnet/csrun:10

The result includes the Microsoft Testing Platform test summary, including discovered, passed, failed, and skipped tests.

Both commands return the actual execution exit code.

⁠Available images

Image tagSDK environment
10.NET 10
11.NET 11
10-11.NET 10 and .NET 11

Each environment also provides its corresponding .NET and ASP.NET Core runtimes.

Images support Linux AMD64 and ARM64.

Exact SDK patch versions and corresponding environment aliases are published alongside the major-version tags.

There is intentionally no latest Docker tag. Tags describe installed SDK environments rather than csrun application versions. See the available tags⁠.

⁠Features

  • Zero project setup: Execute complete C# source directly without creating a conventional project.
  • Real unit testing: Discover and run xUnit v3 tests through Microsoft Testing Platform.
  • Pinned dependencies: Reference exact NuGet package versions through the manifest.
  • Multiple frameworks: Choose supported .NET SDK environments explicitly.
  • Disposable execution: Generated source, build artifacts, and temporary package caches remain inside the container.
  • Predictable exit codes: Preserve compilation failures, application exit codes, and test results.
  • Unprivileged execution: Run as a non-root user without implicit host mounts or Docker socket access.
  • Verifiable delivery: Multi-architecture image builds undergo native execution tests and OCI artifact verification, including SBOM and provenance checks.

⁠JSON manifest

csrun accepts a versioned JSON manifest:

{
  "schemaVersion": 1,
  "mode": "console",
  "framework": "net10.0",
  "dependsOn": [
    "[email protected]"
  ],
  "source": "Console.WriteLine(42);"
}

Use console for applications or test for xUnit tests. Dependencies are optional and must use exact package versions.

For detailed manifest options and examples, see the GitHub README⁠.

⁠Isolation and security

csrun containers run as an unprivileged user and do not automatically mount host directories, credentials, or the Docker socket.

The containerized execution environment is disposable, but Docker isolation is not a security guarantee for arbitrary untrusted code. Network access remains enabled for .NET release metadata and NuGet package retrieval.

Use additional Docker restrictions when appropriate, including read-only filesystems, dropped capabilities, and resource limits.

The image builds verify the bundled csrun engine checksum and associated SDK identities. Published OCI content also undergoes platform, provenance, and SBOM verification.

⁠Native execution and independent publishing

The same csrun engine is available as a standalone PowerShell 7 script for developers with a compatible local .NET SDK.

The repository also includes BuildAndPublish, a PowerShell module for building, validating, and publishing custom SDK container images independently of Codebelt's CI/CD infrastructure.

Forks can configure their own registry, Docker builders, and engine source.

⁠Source and license

Developed and maintained as part of the Codebelt⁠ ecosystem.

Write C#. Run it. Test it. Dispose of it.

Tag summary

Content type

Image

Digest

sha256:19fdfd390…

Size

564 MB

Last updated

4 days ago

docker pull codebeltnet/csrun:10-11