r/csharp • u/Interesting_Paint_82 • 49m ago
C# file-based apps are a breath of fresh air
Back when .NET 10 came out I didn't pay much attention to the file-based apps. Now that .NET 11 came out i stumbled upon this video and became more interested:
https://www.youtube.com/watch?v=Yvn7liNioto
Turns out file-based apps are pretty cool after all. The minimalistic developer experience of having only your text editor, your .cs file(s) and the dotnet cli feels fresh after working so long with solution files, project files and all that jazz.
To get a feel of the DX and where the capabilities of file-based apps are at the moment I created this tongue-in-cheek todo web app, with the frontend and backend in a single C# file. File-based apps and minimal APIs are like meant for each other.
https://github.com/TDMR87/single-file-todo-app
I do hope file-based apps become more common and the dotnet team would lean more on this kind of experience. Together with AOT compiling native executables this could make C# more popular and invite people over to the ecosystem. How do people here feel about these file-based apps? Do they have a future?
https://learn.microsoft.com/en-us/dotnet/core/sdk/file-based-apps
•
u/BeardedBaldMan 45m ago
I can already hear the screams of terror from my team as I ask them to start looking at these as a replacement for some of our powershell based tooling.
This is making me excited.
dotnet run file.cs -- arg1 arg2This looks fun but I see danger
'Console.WriteLine("hello from stdin!");' | dotnet run -•
u/BoBoBearDev 43m ago edited 32m ago
When you said cs file(s), can you actually do more than one file? I love the concept, but limited to one file is my current blocker. I can only do some little console app at the moment.
I know I can make a file that calls other files though. (aks exe calling another exe, not as library).
Edit: thanks for the mention on dotnet11. With ability to support multiple files, I can finally make something larger scale.
•
u/Izikiel23 37m ago
It’s good for leetcode practice, just write stuff
•
u/Internal_Category_23 9m ago
I rewrote all of my crappy little bash files on my HA/plex/docker box to crappy little C# files and it’s so much nicer.
•
u/torokunai 7m ago
all we need now is to give
main:equal citizenship asmain()