Description
Description
I would like to have support for appsettings.json
so I can use settings configured in this file in my MAUI app.
When this is implemented, adding an appsettings.json
file to your MAUI project will automatically load the configuration inside it.
I'm using the following code to workaround this issue.
var builder = MauiApp.CreateBuilder();
builder
.RegisterBlazorMauiWebView()
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
})
.Host
.ConfigureAppConfiguration((app, config) =>
{
var assembly = typeof(App).GetTypeInfo().Assembly;
config.AddJsonFile(new EmbeddedFileProvider(assembly), "appsettings.json", optional: false, false);
});
Public API Changes
I believe no public API changes are necessary
Intended Use-Case
Currently I'm trying to get my Blazor WebAssembly app to work in .NET MAUI. To make this possible I've created a Razor Class Library that contains all the shared components. In this project I also setup my dependency container which needs access to settings I have configured in an appsettings.json
file.
In my Blazor WebAssembly app a call to WebAssemblyHostBuilder.CreateDefault(args);
will automatically load the neccessary appsettings.json
files. It would be great if the same can be done for MauiApp.CreateBuilder();