Me.Toolkit.Maui.Hosting 26.9.14

dotnet add package Me.Toolkit.Maui.Hosting --version 26.9.14
                    
NuGet\Install-Package Me.Toolkit.Maui.Hosting -Version 26.9.14
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Me.Toolkit.Maui.Hosting" Version="26.9.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Me.Toolkit.Maui.Hosting" Version="26.9.14" />
                    
Directory.Packages.props
<PackageReference Include="Me.Toolkit.Maui.Hosting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Me.Toolkit.Maui.Hosting --version 26.9.14
                    
#r "nuget: Me.Toolkit.Maui.Hosting, 26.9.14"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Me.Toolkit.Maui.Hosting@26.9.14
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Me.Toolkit.Maui.Hosting&version=26.9.14
                    
Install as a Cake Addin
#tool nuget:?package=Me.Toolkit.Maui.Hosting&version=26.9.14
                    
Install as a Cake Tool

Me.Toolkit.Maui.Hosting

Sets the host environment name of a .NET MAUI app, so IsDevelopment() means something.

Ported from Xamarinme.Hosting — and it is deliberately much smaller than what it replaces.

Use

using Me.Toolkit.Maui.Hosting;

var builder = MauiApp.CreateBuilder();
builder.UseMeToolkitMauiHosting("Development");

Or take the name from configuration, which is how Xamarinme.Hosting worked:

builder.Configuration.AddAppPackageJson();
builder.UseMeToolkitMauiHostingFromConfiguration();     // reads "MAUI_ENVIRONMENT"
{ "MAUI_ENVIRONMENT": "Development" }

The key is read when IHostEnvironment is first resolved, not when the call is made, so the order of the two lines does not matter. Pass a different key if MAUI_ENVIRONMENT does not suit; Xamarinme called it XAMARIN_ENVIRONMENT.

Then inject the framework's own interface — there is no Me.Toolkit.Maui-specific one:

public sealed class Service(IHostEnvironment environment)
{
    public bool IsDev => environment.IsDevelopment();
}

What comes from the platform

Only the environment name is Me.Toolkit.Maui's. ApplicationName, ContentRootPath and ContentRootFileProvider are delegated to MAUI's own host environment, unchanged — including their failure modes.

ContentRootPath throws NotImplementedException on Android, and this package passes that through rather than inventing a value. Verified on a device. If you need a writable path, use FileSystem.AppDataDirectory; if you need one for an ASP.NET Core content root, AppContext.BaseDirectory is what Me.Toolkit.Maui.WebHostPatch defaults to.

Why this is so small

Xamarinme.Hosting existed because Xamarin had no hosting at all. It built a parallel XamarinHostBuilder exposing Configuration, Services, Logging and an environment, plus an IHost that threw NotImplementedException from both StartAsync and StopAsync.

MauiAppBuilder is that builder, and MAUI registers an IHostEnvironment of its own. The only gap is that MAUI's always reports Production and its EnvironmentName setter throws. This package wraps it, so the name can change while ApplicationName and ContentRootPath keep coming from the platform.

If you only ever need a constant environment name, you do not need this package — but you do need to wrap rather than assign, which is the part that is easy to get wrong.

Documentation

Full documentation is in the wikiDesign Notes for why each library is shaped the way it is, Building and Testing for the multi-targeting rules, and Publishing for how these packages are released.

Source: github.com/melihercan/Me.Toolkit.Maui

Licence

MIT.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-maccatalyst26.0 is compatible.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net10.0-windows10.0.19041 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.9.14 77 9/14/2026
26.9.9 85 9/8/2026

26.9.9 renames the assemblies and namespaces to match the package ID. 26.9.8 shipped the correct package ID around assemblies still called Mauime.*, so consuming it meant writing using Mauime.X against a package called Me.Toolkit.Maui.X; it is unlisted. Nothing else changed.
First release. Replaces Xamarinme.Hosting 1.0.3, and is deliberately far smaller.
Xamarinme.Hosting existed because Xamarin had no hosting at all: it built a parallel XamarinHostBuilder exposing Configuration, Services, Logging and an environment, plus an IHost that threw NotImplementedException from both StartAsync and StopAsync. MauiAppBuilder is that builder, and MAUI registers an IHostEnvironment, so the environment name is all that was left to do.
UseMeToolkitMauiHosting sets the name. UseMeToolkitMauiHostingFromConfiguration reads it from a MAUI_ENVIRONMENT key, renamed from XAMARIN_ENVIRONMENT, when IHostEnvironment is first resolved - so it does not matter whether the configuration sources were added before or after.
The platform environment is wrapped rather than assigned to, because MauiHostEnvironment.EnvironmentName throws from its setter even though the interface declares it. ApplicationName and ContentRootPath still come from the platform.
There is no Me.Toolkit.Maui-specific environment interface. Inject the framework's IHostEnvironment.