.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 Serilog@4.3.0
#:package Serilog.Sinks.Console@6.0.0

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

Looking for a developer for your next project?? Contact our team at our Adelaide Head Office to discuss custom hosting solutions that fit your business perfectly.

Adelaide | Head Office Digitize, Suite 26, Marnirni-apinthi Building, Lot Fourteen, North Terrace, Adelaide, SA 5000, Australia
Phone: +61 (08) 7081 1100

Related articles

WordPress Updates, How Do They Work?

Stay ahead of the curve with our WordPress update services. We ensure your website is always running the latest version, benefiting from new features, improved performance, and crucial security patches. Don't let outdated software hold you back. Choose our WordPress update services for a smooth, secure, and enhanced website experience

Read More

Importance of Online Presence: Why it Matters

An online presence is crucial in today's digital age. It allows your business to reach a global audience, operate beyond traditional hours, and engage with customers in new ways. A strong online presence can enhance your brand's visibility, build credibility, and drive business growth by attracting new customers and fostering stronger relationships with existing ones.

Read More

Microsoft Azure and its Benefits for Your Business

Microsoft Azure offers scalable cloud services, cost-effectiveness, robust security, and seamless integration with other Microsoft products. Ideal for businesses of all sizes.

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.