.NET 10 is here with our favourite feature dotnet run
Dots pattern

.NET 10 Is Here and It’s About to Make C# Scripting Awesome

Microsoft just released .NET 10, and while it brings plenty of performance and language improvements, there’s one new trick that we’re really excited about — you can now run a C# file directly with:

dotnet run Program.cs

No projects. No .csproj. No setup. Just write your C# file and run it like a script.

It might sound like a small thing, but for sysadmins, MSPs, and anyone managing servers or containers, this changes everything.


C# That Feels Like a Script Language

Before .NET 10, even the simplest program required creating a full project. Now you can skip all that and just execute a single .cs file — it compiles and runs behind the scenes automatically.

You get the power and structure of C# with the convenience of PowerShell, Bash, or Python. It’s the best of both worlds — typed, fast, and cross-platform.

Here’s an example:

Console.WriteLine("Disk usage for C:\\");
foreach (var drive in System.IO.DriveInfo.GetDrives())
{
    if (drive.IsReady && drive.Name == "C:\\")
    {
        Console.WriteLine($"Total: {drive.TotalSize/1_000_000_000} GB");
        Console.WriteLine($"Free : {drive.AvailableFreeSpace/1_000_000_000} GB");
    }
}

Then simply run:

dotnet run MonitorDisk.cs

That’s it. Your script runs immediately.

You can even pull in NuGet packages with inline directives — no project file required:

#:package [email protected]
#:package [email protected]

using Serilog;

Log.Logger = new LoggerConfiguration()
    .WriteTo.Console()
    .CreateLogger();

Log.Information("Starting up Serilog demo...");

for (int i = 1; i <= 5; i++)
{
    Log.Information("Iteration {Count}", i);
    await Task.Delay(500);
}

Log.CloseAndFlush();

It’s clean, lightweight, and incredibly useful for quick jobs or one-off utilities.

What’s happening?

The #:package directives are a new .NET 10 feature. They tell the SDK to automatically pull NuGet packages when you run the file — no .csproj needed.

Everything after that is normal C# code using Serilog.

When you use dotnet run Program.cs on Windows, the SDK automatically creates a temporary working directory for your script under:

C:\Users\<username>\AppData\Local\Temp\dotnet\runfile\

That’s where it builds and executes your C# file behind the scenes. The whole process is transparent — you don’t need to manage those files yourself, and they’re cleaned up automatically after each run.


Yes, It Works on Linux Too (With a Shebang!)

This isn’t just a Windows thing — .NET 10 lets you use the shebang syntax on Linux and macOS to run your scripts just like Bash or Python.

You can write a script such as cleanup.cs like this:

#!/usr/bin/env dotnet run
Console.WriteLine("Cleaning up temp files...");
System.IO.Directory.GetFiles("/tmp")
    .ToList()
    .ForEach(System.IO.File.Delete);

Then make it executable:

chmod +x cleanup.cs

Now you can run it directly:

./cleanup.cs

That’s right — C# is officially a first-class scripting language on Linux now. You can use it for cron jobs, maintenance scripts, container automation, or just quick admin tools, all using the same runtime and language you already use for your production apps.


Why MSPs and Sysadmins Should Care

For anyone running servers or hosting infrastructure, this is a major quality-of-life improvement. You can use .NET 10’s scripting mode to:

Write quick utilities without spinning up full projects.

Stay entirely within the C# ecosystem — no need to jump to PowerShell or Bash.

Run the same scripts across Windows and Linux environments.

Use real NuGet packages in your scripts for logging, HTTP calls, JSON parsing, etc.

Convert any script into a proper project later with dotnet project convert Program.cs.

It’s fast, flexible, and fits right into the way MSPs and DevOps teams actually work.


A Great Fit for Modern Infrastructure

In our own deployments we’re constantly writing small utilities for Active Directory health checks, backup cleanup, log analysis, and monitoring agents.

Before, that usually meant juggling PowerShell, Bash, or a quick Python script. Now, we can do it all in C#, in a consistent runtime that already exists across our infrastructure.

The benefits are obvious:

  • Unified language for automation, tools, and services.
  • Cross-platform compatibility (Windows, Linux, containers).
  • Long-term support from .NET 10 (LTS release = stability).
  • No setup overhead for small scripts — write and run.

The Bigger Picture

.NET 10 also ships with:

Big runtime performance improvements.

New C# 14 features (cleaner syntax, smarter lambdas).

Better container and tooling support (great for CI/CD pipelines).

Extended cryptography and post-quantum readiness.

But honestly, the single-file scripting support steals the show for us. It’s the simplest change that unlocks a ton of practical new workflows — from quick server tasks to lightweight monitoring scripts.

Is this our favourite release?

The ability to type:

dotnet run script.cs

or even

./script.cs

and have a C# script just run feels like a quiet revolution. For anyone who lives in Windows or Linux terminal windows all day, it’s one of those features that immediately makes life easier.

We’ll be using it heavily for our own Windows automation workflows — and it’s safe to say, C# just became a few people's favourite scripting language.

To find out more you can read the full release notes at released .NET 10

Related articles

Custom Software Application Development: Tailoring Solutions for Your Business

Unlock your business potential with our tailored custom software solutions. Designed to fit your unique needs, our software enhances operational efficiency, drives innovation, and gives you a competitive edge. Experience the perfect blend of functionality, scalability, and performance with our custom software solutions.

Read More

The importance of updating and maintaining Ruby on Rails applications

Boost your Ruby on Rails application's performance, security, and efficiency with our gem upgrades. Experience seamless integration, improved functionality, and the latest features that keep your app ahead of the curve. Upgrade your gems today and unlock the full potential of your Rails application!

Read More

Custom Software Application Development: A Comprehensive Guide

Bring your unique business ideas to life with our custom software application development services. We tailor solutions to fit your specific needs, ensuring efficiency, scalability, and robust functionality. Partner with us to create software that not only meets your current requirements but also adapts to future growth and changes.

Read More
Get In Touch

Why partner with Digitize?

At Digitize, we are a focused team that invest constantly in improving so that we can provide the best capabilities to our clients. Our processes and teams are built around being flexible so we can deliver tailored solutions instead of trying to make existing solutions fit.

Each client has a dedicated account manager that will ensure you are always getting the best service possible.