### Verify Xcode Installation Path Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md This command verifies that Xcode is installed and returns the path to its installation directory. This is useful for troubleshooting when Xcode is not found by the .NET MAUI setup. ```console xcode-select -p ``` -------------------------------- ### IDeviceInstallationService Interface for .NET MAUI Source: https://github.com/dotnet/docs-maui/blob/main/docs/data-cloud/push-notifications.md Defines the contract for a service responsible for retrieving device installation information. It includes properties for the token and notification support, methods to get a device ID, and to retrieve device installation details with optional tags. This interface is intended for platform-specific implementations. ```csharp using PushNotificationsDemo.Models; namespace PushNotificationsDemo.Services; public interface IDeviceInstallationService { string Token { get; set; } bool NotificationsSupported { get; } string GetDeviceId(); DeviceInstallation GetDeviceInstallation(params string[] tags); } ``` -------------------------------- ### List Installed .NET MAUI Workloads Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md Lists all installed .NET MAUI workloads on your system. This command helps in verifying the installation status of various MAUI components, including Android and Windows specific workloads. ```dotnetcli dotnet workload list ``` -------------------------------- ### Install Android Emulator and System Images (Windows) Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md Installs the Android emulator and a system image for API level 35 on Windows using the `sdkmanager` command. Requires the Android SDK command-line tools to be in the system's PATH. ```console sdkmanager --install emulator ``` ```console sdkmanager --install "system-images;android-35;google_apis;x86_64" ``` -------------------------------- ### Install Xcode Command Line Tools Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md Acquires the Xcode command line tools necessary for .NET MAUI development on iOS and Mac Catalyst by running the `xcode-select --install` command in the terminal. ```console xcode-select --install ``` -------------------------------- ### PUT /api/notifications/installations Source: https://github.com/dotnet/docs-maui/blob/main/docs/data-cloud/push-notifications.md Creates or updates a device installation for push notifications. Requires device installation details in the request body. ```APIDOC ## PUT /api/notifications/installations ### Description Creates or updates a device installation for push notifications. Requires device installation details in the request body. ### Method PUT ### Endpoint /api/notifications/installations ### Parameters #### Request Body - **deviceInstallation** (DeviceInstallation) - Required - The details of the device installation. ### Request Example ```json { "deviceId": "string", "pushChannel": "string", "tags": ["string"] } ``` ### Response #### Success Response (200) - **None** - Indicates the installation was successfully created or updated. #### Error Response - **400 Bad Request** - If the request is invalid. - **422 Unprocessable Entity** - If the operation could not be processed. ``` -------------------------------- ### Install .NET MAUI Workload on Windows Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md Installs the .NET MAUI workload on Windows using the .NET CLI. This command enables development for MAUI applications on the Windows platform. ```dotnetcli dotnet workload install maui ``` -------------------------------- ### Install .NET MAUI Workload Source: https://github.com/dotnet/docs-maui/blob/main/docs/includes/install-create-macos.md Installs the .NET MAUI workload, including necessary platform SDKs, from the specified NuGet source. This is a prerequisite for developing .NET MAUI apps. ```zsh sudo dotnet workload install maui --source https://api.nuget.org/v3/index.json ``` -------------------------------- ### Install .NET MAUI Workload using CLI Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md These commands install the .NET MAUI workload necessary for developing .NET MAUI applications. The specific command varies slightly by operating system. ```dotnetcli dotnet workload install maui ``` ```dotnetcli sudo dotnet workload install maui ``` ```dotnetcli dotnet workload install maui-android ``` -------------------------------- ### Implement Page Navigation with Button Source: https://github.com/dotnet/docs-maui/blob/main/docs/xaml/fundamentals/get-started.md Creates a Button in the constructor of a .NET MAUI MainPage and assigns a click event handler to navigate to another page (HelloXamlPage). This code snippet shows how to programmatically instantiate UI elements and handle user interactions for navigation. ```csharp public MainPage() { InitializeComponent(); Button button = new Button { Text = "Navigate!", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }; button.Clicked += async (sender, args) => { await Navigation.PushAsync(new HelloXamlPage()); }; Content = button; } ``` -------------------------------- ### Install Android Emulator and System Images (macOS) Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md Installs the Android emulator and a system image for API level 35 on macOS using the `sdkmanager` command. This command assumes an Apple Silicon Mac; replace `arm64-v8a` with `x86_64` for Intel Macs. ```console ./sdkmanager --install emulator ``` ```console ./sdkmanager --install "system-images;android-35;google_apis;arm64-v8a" ``` -------------------------------- ### Configure MAUI App Display Name and Description for Windows Start Menu Entry Source: https://github.com/dotnet/docs-maui/blob/main/docs/windows/setup.md This XML snippet demonstrates how to set the display name and description for a .NET MAUI Windows app's Start Menu entry by modifying the `` element within the _Package.appxmanifest_ file. ```xml ``` -------------------------------- ### C# Code-Behind for MAUI Page Source: https://github.com/dotnet/docs-maui/blob/main/docs/xaml/fundamentals/get-started.md This C# snippet represents the code-behind file for a .NET MAUI page defined in XAML. It declares a partial class that inherits from `ContentPage` and includes a constructor that calls `InitializeComponent()`. This method is responsible for loading and initializing the UI elements defined in the associated XAML file. ```csharp namespace MyMauiApp; public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } } ``` -------------------------------- ### Install Xcode Command Line Tools for iOS/macOS Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md This command installs the necessary command line tools for Xcode, which are essential for .NET MAUI development on iOS and macOS. It should be run in the terminal. ```console xcode-select --install ``` -------------------------------- ### Define Device Installation Model in C# Source: https://github.com/dotnet/docs-maui/blob/main/docs/data-cloud/push-notifications.md The `DeviceInstallation` class represents a device installation in Azure Notification Hubs. It includes properties for `InstallationId`, `Platform`, `PushChannel`, and optional `Tags`. This model is used to register and manage devices that will receive push notifications. ```csharp using System.ComponentModel.DataAnnotations; namespace PushNotificationsAPI.Models; public class DeviceInstallation { [Required] public string InstallationId { get; set; } [Required] public string Platform { get; set; } [Required] public string PushChannel { get; set; } public IList Tags { get; set; } = Array.Empty(); } ``` -------------------------------- ### Install .NET Upgrade Assistant via CLI Source: https://github.com/dotnet/docs-maui/blob/main/docs/migration/upgrade-assistant.md Installs the .NET Upgrade Assistant globally using the dotnet CLI. This command makes the upgrade-assistant tool available system-wide. ```dotnetcli dotnet tool install -g upgrade-assistant ``` -------------------------------- ### Configure .NET MAUI iOS Project SDK Source: https://github.com/dotnet/docs-maui/blob/main/docs/migration/apple-projects.md Example .NET 8 project configuration for a .NET for iOS app using the Microsoft.NET.Sdk. This setup enables features like nullable reference types and implicit usings, and specifies the target framework and supported OS platform version. ```xml net8.0-ios Exe enable true 13.0 ``` -------------------------------- ### Implement Device Installation Service for Android Source: https://github.com/dotnet/docs-maui/blob/main/docs/data-cloud/push-notifications.md This C# class, `DeviceInstallationService`, implements `IDeviceInstallationService` for Android. It retrieves the device ID using `Secure.AndroidId`, checks for Google Play Services availability, and constructs the device installation payload for push notifications. ```csharp using Android.Gms.Common; using PushNotificationsDemo.Models; using PushNotificationsDemo.Services; using static Android.Provider.Settings; namespace PushNotificationsDemo.Platforms.Android; public class DeviceInstallationService : IDeviceInstallationService { public string Token { get; set; } public bool NotificationsSupported => GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(Platform.AppContext) == ConnectionResult.Success; public string GetDeviceId() => Secure.GetString(Platform.AppContext.ContentResolver, Secure.AndroidId); public DeviceInstallation GetDeviceInstallation(params string[] tags) { if (!NotificationsSupported) throw new Exception(GetPlayServicesError()); if (string.IsNullOrWhiteSpace(Token)) throw new Exception("Unable to resolve token for FCMv1."); var installation = new DeviceInstallation { InstallationId = GetDeviceId(), Platform = "fcmv1", PushChannel = Token }; installation.Tags.AddRange(tags); return installation; } string GetPlayServicesError() { int resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(Platform.AppContext); if (resultCode != ConnectionResult.Success) return GoogleApiAvailability.Instance.IsUserResolvableError(resultCode) ? GoogleApiAvailability.Instance.GetErrorString(resultCode) : "This device isn't supported."; return "An error occurred preventing the use of push notifications."; } } ``` -------------------------------- ### Configure MAUI App Icon for Windows Start Menu Entry Source: https://github.com/dotnet/docs-maui/blob/main/docs/windows/setup.md This XML snippet shows how to configure the application icon for the .NET MAUI Windows Start Menu entry by modifying the `` element in the project file. It specifies the foreground file and color for the icon. ```xml ``` -------------------------------- ### Install .NET MAUI Workload on macOS Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md Installs the .NET MAUI workload on macOS using the .NET CLI with administrative privileges. This is necessary for developing MAUI applications on macOS. ```dotnetcli sudo dotnet workload install maui ``` -------------------------------- ### List Installed .NET Versions Source: https://github.com/dotnet/docs-maui/blob/main/docs/troubleshooting.md This command provides detailed information about all installed .NET versions on the system, including SDKs, runtimes, and their locations. It's a useful diagnostic tool for identifying potential version conflicts that affect .NET MAUI template availability. ```bash dotnet --info ``` -------------------------------- ### Install .NET Upgrade Assistant with Ignore Failed Sources Source: https://github.com/dotnet/docs-maui/blob/main/docs/migration/upgrade-assistant.md Installs the .NET Upgrade Assistant globally, ignoring any failures related to NuGet feed sources. This is useful if you have custom NuGet feeds configured that might cause installation issues. ```dotnetcli dotnet tool install -g --ignore-failed-sources upgrade-assistant ``` -------------------------------- ### Set ContentPage Content with XAML Source: https://github.com/dotnet/docs-maui/blob/main/docs/xaml/fundamentals/get-started.md Defines the structure and content of a .NET MAUI ContentPage using XAML. It includes a Label with various text formatting properties. This demonstrates how XAML elements map to .NET MAUI classes and their properties. ```xaml ``` -------------------------------- ### Install .NET xcsync CLI Tool (Global) Source: https://github.com/dotnet/docs-maui/blob/main/docs/macios/xcsync.md Installs the preview version of the .NET xcsync tool globally. This command requires a specific NuGet feed for the prerelease version. It is a prerequisite for using xcsync commands via the CLI or Visual Studio Code extension. ```dotnetcli dotnet tool install dotnet-xcsync -g --prerelease --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json ``` -------------------------------- ### Install .NET MAUI Workload for Android on Linux Source: https://github.com/dotnet/docs-maui/blob/main/docs/get-started/installation.md Installs the .NET MAUI workload specifically for Android development on Linux. This command enables the creation of Android applications using .NET MAUI on Linux systems. ```dotnetcli dotnet workload install maui-android ``` -------------------------------- ### Launch Android Emulator from Command Line Source: https://github.com/dotnet/docs-maui/blob/main/docs/android/emulator/troubleshooting.md This command starts the Android emulator from the command line with specific AVD configurations. It allows for detailed output and control over emulator startup parameters, useful for debugging. ```cmd "C:\Program Files (x86)\Android\android-sdk\emulator\emulator.exe" -partition-size 2000 -no-boot-anim -verbose -feature WindowsHypervisorPlatform -avd pixel_5_-_api_30 -prop monodroid.avdname=pixel_5_-_api_30 ``` -------------------------------- ### Manage Device Installations in .NET MAUI Azure Notification Hubs Source: https://github.com/dotnet/docs-maui/blob/main/docs/data-cloud/push-notifications.md Handles the creation, updating, and deletion of device installations with Azure Notification Hubs. It validates input parameters such as InstallationId, Platform, and PushChannel, and maps platform names to the NotificationPlatform enum. Errors during hub operations are caught and logged. ```csharp private Dictionary _installationPlatform; _installationPlatform = new Dictionary { { nameof(NotificationPlatform.Apns).ToLower(), NotificationPlatform.Apns }, { nameof(NotificationPlatform.FcmV1).ToLower(), NotificationPlatform.FcmV1 } }; public async Task CreateOrUpdateInstallationAsync(DeviceInstallation deviceInstallation, CancellationToken token) { if (string.IsNullOrWhiteSpace(deviceInstallation?.InstallationId) || string.IsNullOrWhiteSpace(deviceInstallation?.Platform) || string.IsNullOrWhiteSpace(deviceInstallation?.PushChannel)) return false; var installation = new Installation() { InstallationId = deviceInstallation.InstallationId, PushChannel = deviceInstallation.PushChannel, Tags = deviceInstallation.Tags }; if (_installationPlatform.TryGetValue(deviceInstallation.Platform, out var platform)) installation.Platform = platform; else return false; try { await _hub.CreateOrUpdateInstallationAsync(installation, token); } catch { return false; } return true; } public async Task DeleteInstallationByIdAsync(string installationId, CancellationToken token) { if (string.IsNullOrWhiteSpace(installationId)) return false; try { await _hub.DeleteInstallationAsync(installationId, token); } catch { return false; } return true; } ``` -------------------------------- ### Define Basic UI Layout in XAML for .NET MAUI Source: https://github.com/dotnet/docs-maui/blob/main/docs/xaml/fundamentals/get-started.md This XAML code defines the basic structure of a user interface in a .NET MAUI application, including a StackLayout containing a Slider, Label, and Button. It sets up the visual elements that will be interacted with via code. ```xaml