This should become possible in .NET 10. Basically, you will be able to dotnet run app.cs
.
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.