NextBuild

Run C# Scripts With dotnet run app.cs (No Project Files Needed)

Run C# Scripts With dotnet run app.cs (No Project Files Needed)

Run C# Scripts With dotnet run app.cs (No Project Files Needed)

.NET 10 just got a whole lot more lightweight. This means you no longer need to create a project file or scaffold a whole application to run a quick script, test a snippet, or experiment with an idea. It’s simple, intuitive, and designed to streamline the C# development experience, especially for those just getting started.


What is dotnet run app.cs?

Until now, executing C# code using the dotnet CLI required a project structure that included a .csproj file. With this new capability, which we call file-based apps, you can run a standalone .cs file directly, much like you would with scripting languages such as Python or JavaScript.

This lowers the entry barrier to trying out C# and makes the language a much more attractive choice for learning, prototyping, or automation scenarios.

Quick Start, No Project File Required – Great for learning, experimentation, and small scripts.
First-Class CLI Integration – No extra tools, no dependencies, just dotnet and your .cs file.
Scales to Real Applications – This isn’t a separate dialect or runtime. When your script grows up, it can evolve into a full-fledged project using the same language, syntax, and tooling.


You can now run a C# file directly with:

dotnet run app.cs


That's it. No .csproj. No Program.cs. No solution files. Just a single C# file.


Why This Is a Big Deal

Historically, C# and .NET required a lot of boilerplate to get started. Even printing “Hello World”.

Now, anyone can get started with just a single file. This is huge for students, hobbyists, and those trying C# for the first time. And it runs on any OS with the .NET SDK installed.


Getting Started

Install .NET 10 Preview 4 Download and install it from dotnet.microsoft.com.

Install Visual Studio Code (recommended) If you’re using Visual Studio Code, install the C# Dev Kit

Write your code Create a file called hello.cs:

Console.WriteLine("Hello, world!");

Run it! Open a terminal in the same folder and run:

dotnet run hello.cs

Convert to a project To convert the file to a project, run:

dotnet project convert hello.cs


The ceremony is dead. Long live practical C#.

  • Share:

  • Share on X