Every couple of weeks I need a twenty-line program. Find what's bloating a build agent's disk, dedupe a CSV, hash-check a folder. For fifteen years the honest answer to "which language?" was not C# — by the time I'd done mkdir, dotnet new console, and named yet another throwaway csproj, the moment had passed. So those little jobs went to bash or Python, and I grumbled quietly every time.
.NET 10 removed the ritual. You write one .cs file and run it. I'd been meaning to check how well this actually holds up for real scripts, so this week I did — nothing fancy, one Linux container and a stopwatch.
One file, no project
Here's biggest.cs, a small utility that lists the largest files under a directory. The whole program is this one file — no csproj anywhere:
#!/usr/bin/env dotnet
#:package [email protected]
using Humanizer;
var root = args.Length > 0 ? args[0] : ".";
var top = args.Length > 1 && int.TryParse(args[1], out var n) ? n : 10;
var files = new
Discussion
Be the first to comment
Add your perspective to get the discussion started.