We are super excited to introduce a new feature that was released as part of .NET 10 Preview 4 that makes getting started with C# easier than ever. You can now run a C# file directly using dotnet run app.cs. 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. New file-level directives for file-based C# apps With .NET 10 Preview 4, file-based apps also support a set of powerful file-level directives that allow to declare a small number of important things that are stored in project files for project-based apps, all without leaving your single .cs file. These directives make file-based apps more flexible and expressive while maintaining compatibility with MSBuild concepts. Referencing NuGet packages with #:package You can add NuGet package references directly in your .cs file using the #:package directive: #:package Humanizer@2.14.1 using Humanizer; var dotNet9Released = DateTimeOffset.Parse("2024-12-03"); var since = Da...
First seen: 2025-05-29 04:03
Last seen: 2025-05-30 03:21