The file app is a new feature in .NET 10 that lets you run a C# source file directly without requiring a project file, like dotnet App.cs. While the build system is tightly integrated with the project file, it operates virtually within the file-based app execution.
Project components like SDK, properties, references, and packages are now defined directly within the C# source file. This is done with the help of C# Ignored Directives. This ensures seamless integration with the virtual project file.
C# – Preprocessor Directives are highly useful for writing code that can be compiled conditionally, depending on factors like the target framework, target platform, or build configuration.
For example:
#if NET9_0_OR_GREATER
// The code within this block will execute only on .NET 9 or higher
#endif
#if ANDROID
// The code within this block will execute only on the Android OS
#endif
#if DEBUG
// The code within this block will execute only in Debug mode
#endif
C# – Ignored Directives have a similar syntax but are ignored by the compiler because they are for tooling.
The real purpose of this feature is to execute a C# source file directly from the CLI. It doesn’t need a project file. Now, even the plain console app requires a project file, despite the much-simplified top-level statements feature.
This September, the .NET MAUI monthly community standup discusses the.NET MAUI 9 release enhancements. The HybridWebView and amazing TitleBar for Windows are just the tip of the iceberg.
Remember to join live on Thu, Sep 5 at 17:30 UTC. Click the link to access the timing in your local or preferred time zone.Note, that it’s half an hour behind the usual schedule.
Update: The community links for this month’s standup are here.
Happy coding. Stay connected as we continue to learn and share the experiences from this exciting journey of being a .NET developer.
Back in February, an article was published on the efficient utilization of Item Templates through the use of script automation. The article, titled .NET MAUI – Item Templates – Made Easy on CLI and VS Code, provides a detailed focus on this topic.
That article addressed two issues:
Better namespace resolution
Do more with fewer keystrokes
Now, the namespace resolution issue has been partially supported within the .NET SDK, eliminating the requirement for additional script files. A PR was submitted to the .NET Templating source repository, underwent review, and was subsequently merged into the main branch. This enhancement was then included in the release of .NET 9 Preview 6.
The topic for this June month’s .NET MAUI community standup is VS Code Updates.
Of late, VS Code has incorporated many new features, such as XAML IntelliSense and Hot Reload, as the end of support for VS for Mac is quickly approaching (Aug 31, 2024).
Update: The community links for this month’s standup are here.
David highlighted using MAUI Nightly Builds in the standup. Projects in the All-in-One templates pack already support utilizing the Nightly builds from version 4.6 onwards. However, setting up the package source from the CI feed involves a few manual steps as detailed in the earlier article.
But, automation is the need of the hour. The upcoming release of templates pack v5.6, scheduled for this week, will streamline the process by eliminating manual steps, ensuring seamless functionality when selecting the Nightly builds option upon project creation. Cool 😊.
Update: v5.6 has just been released. Consult this article for further details.
Remember to join live on Thu, Jun 6 at 17:00 UTC. Click the link to access the timing in your local/preferred time zone. Note, it’s back at the same time.
Happy coding. Stay connected as we continue to learn and share the experiences from this exciting journey of being a .NET developer.
VS Code - .NET MAUI - Select Startup Project and Debug Target
In August 2023, Microsoft made an official announcement regarding the retirement of Visual Studio for Mac, scheduled to take place by August 31, 2024 (in another 6 months), as stated in a blog post here.
In the same blog post, Visual Studio Code along with the C# Dev Kit is projected as a viable alternative for cross-platform .NET development. For further information on the C# Dev Kit, refer to this article.
And for .NET MAUI too, there’s an officially supported extension hosted on VS Marketplace. To know more about this, take a look at this article. C# Dev Kit is a dependency for this .NET MAUI extension.
In light of the recent announcements, the article has been updated to incorporate info on support for JetBrains Rider IDE at the conclusion.
At first, .NET 6 and .NET 7 versions of .NET MAUI were released only via SDK Workloads whereas from .NET 8 onwards (Preview 4 to be precise), it is now distributed as a base workload and suite of NuGet packages on top of it.
This NuGet-based release process allows trying different versions of .NET MAUI which are released on top of a base workload on the same machine without the complexities of moving between different workload versions.
A detailed blog post describing the Vision for .NET 9 is here. Moving forward, preview releases will be published in the GitHub discussion and for Preview 1 here.
And what’s changed in this .NET MAUI 9 Preview 1 is here. Have a look at the tentatively planned features on .NET 9 here and Roadmap here.
Even though the All-in-One item templates have the same set of features in VS2022 and on the CLI. The CLI has its own limitations and here are the notable ones:
The namespace resolution is not on par with its VS counterpart
On CLI – Defaults to the root namespace
Whereas in VS to the exact folder where the item is created
A lot of (repeated) typing is required
The underlying reason is CLI’s named parameters design
.NET 8 is the next LTS release and is currently in preview. .NET, .NET MAUI, and Visual Studio 2022 release a public preview every month for quite some time.
On Tue, Jul 11, another preview version of .NET 8 got released along with VS2022 17.7.0 Preview 3.0.
After installing the latest preview bits, the Android projects failed to build. Upon investigation, found that the Android SDK location got reset to the “Program Files” folder. Since I’ve been working with .NET MAUI from the early prerelease, the Android SDK was originally installed in the Android\Sdk sub-folder in the user’s local application data folder (then recommended path to install).