Categories
.NET .NET 10 .NET MAUI .NET MAUI 10 Android ASP.NET Core Aspire Blazor C# CLI Code Deep Dive Desktop Developer DevOps General Getting Started Hybrid Integration iOS macOS Mobile Visual Studio VS Code Web Windows Xamarin Xamarin.Forms

Integrating .NET MAUI with Aspire: A Comprehensive Guide

Aspire is now the talk of the town. You can build and orchestrate all the dependencies from one single place. In fact, it’s stack streamlined. Learn more about Aspire here.

This article discusses how to integrate .NET MAUI, Microsoft’s cross-platform UI framework, with Aspire.

Aspire supports .NET by default, but since .NET MAUI is designed for multi-targeting from a single project, it presents a minor issue. I’ll offer a workaround until it’s officially supported (coming soon).

For this, I’m using .NET 10 File-based Apps for simplicity. Aspire v9.5 supports this new feature. Consult this article to know more about C# File-apps.

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.