Get the latest tech news
Run a C# file directly using dotnet run app.cs
Run C# files instantly with dotnet run app.cs, no project file needed! Coming to .NET 10, try it out today in Preview 4.
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. This tells the tooling to treat the file as if it were part of a web project, enabling features of ASP.NET Core like Minimal APIs and MVC. Install Visual Studio Code (recommended) If you’re using Visual Studio Code, install the C# Dev Kit and then follow these instructions to update the C# extension for file-based apps support: To enable support for file-based apps and directives, you’ll need the latest pre-release version of the C# extension:
Or read this on Hacker News