Categories
.NET .NET 10 C# CLI Code Desktop Developer File Apps Mobile Tips Visual Studio VS Code VS2022 VS2026 Windows

Run C# Source Files Directly in .NET 10

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.

Categories
.NET .NET 10 ASP.NET Core Aspire Automation Azure Blazor C# CLI Code Desktop Developer Getting Started Linux macOS Mobile Visual Studio VS Code Web What's New Windows

Using C# Ignored Directives: A Guide for Programmers

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.

Categories
.NET .NET 9 .NET MAUI Android Blazor C# Desktop Embedding Events General Hybrid iOS macOS Mobile Standup Video Visual Studio VS Code Web What's New Windows WinUI 3 Xamarin Xamarin.Forms

Explore the .NET MAUI 9 Release Enhancements in September Community Standup

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 UTCClick 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.

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Automation Blazor C# Desktop Developer General Getting Started Hybrid iOS macOS Mobile Preview Templates VS Code What's New Windows Xamarin Xamarin.Forms

Elevating .NET MAUI Item Templates: Simplified Namespace Resolution in Latest Release

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.

Categories
.NET .NET MAUI Android Blazor C# Desktop Developer Events General Hybrid iOS macOS Mobile Standup VS Code Web Windows Xamarin Xamarin.Forms

Join Live: .NET MAUI Community Standup

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.

Refer to this article to start Using VS Code for .NET MAUI development.

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 UTCClick 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.

Categories
.NET .NET MAUI Android Blazor C# Desktop Developer DevOps Getting Started Hybrid iOS macOS Mobile Visual Studio VS Code Web Windows Xamarin Xamarin.Forms

Using Visual Studio Code for .NET MAUI Development

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.

Categories
.NET .NET 8 .NET MAUI Android Blazor C# Desktop Developer DevOps Hybrid iOS macOS Mobile Templates Windows Xamarin Xamarin.Forms

.NET MAUI – Nightly Builds

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.

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Blazor C# Desktop Developer F# Getting Started Hybrid iOS macOS Mobile NuGet Templates Visual Studio Web Windows Xamarin Xamarin.Forms

.NET MAUI on .NET 9

Last Tuesday, the first preview of .NET 9, an STS release, was released along with Visual Studio 2022 17.10 Preview 1.0

Nov 2024 Update: An article has already been published detailing the comprehensive features of .NET MAUI 9.

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.

.NET 9 Preview 2 is available now:

Categories
.NET .NET MAUI Android Automation Blazor Deep Dive Desktop Developer General Hybrid iOS Mobile MVVM NuGet Templates Visual Studio VS Code What's New Windows Xamarin Xamarin.Forms

.NET MAUI – Item Templates – Made Easy on CLI and VS Code

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:

  1. 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
  2. A lot of (repeated) typing is required
    • The underlying reason is CLI’s named parameters design
Categories
.NET .NET 8 .NET MAUI Android Developer General Quick Fix Visual Studio Xamarin

.NET MAUI on .NET 8 Preview 6 – Android build issue

.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).