C# 14 introduces file-based apps

Taking a lesson from scripting languages such as Python and JavaScript, Microsoft has introduced a file-based apps capability for the C# language, which is intended to streamline C# development.

Introduced in .NET 10 Preview 4, the new feature allows developers to run a stand-alone C# (.cs) file directly with the command, dotnet run app.cs. Developers no longer need to create a project file or scaffold an entire application to test a test snippet, run a quick script, or experiment with an idea, wrote Damian Edwards, principal architect at Microsoft, in a May 28 blog post announcing the feature. Previously, running C# code using the dotnet CLI has required a project structure that included a .csproj file. Developers can get started with the feature by downloading .NET 10 Preview 4.

File-based apps lower the entry barrier to trying out C# and make the language a more-attractive choice for learning, prototyping, and automation scenarios, Edwards said. Developers get a quick start while no project file is required, there is “first-class” CLI integration, and the capability scales to real applications. There is no separate dialect or runtime; when a script grows up, it can evolve into a full-fledged project using the same language, syntax, and tools. With .NET 10 Preview 4, file-based apps also support a set of file-level directives to declare packages, SDKs, and properties (which are stored in project files for project apps) without leaving a .cs file.

Donner Music, make your music with gear
Multi-Function Air Blower: Blowing, suction, extraction, and even inflation

Leave a reply

Please enter your comment!
Please enter your name here