Run C# console snippets and xUnit v3 tests in disposable .NET 10/11 SDK containers.
2.2K
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.
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.
| Image tag | SDK 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.
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.
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.
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.
Developed and maintained as part of the Codebelt ecosystem.
Write C#. Run it. Test it. Dispose of it.
Content type
Image
Digest
sha256:19fdfd390…
Size
564 MB
Last updated
4 days ago
docker pull codebeltnet/csrun:10-11