JSON Platform Bundle
The JSON Platform Bundle provider allows you to use appsettings.json files just like ASP.NET Core, but from platform-specific bundled locations. This is especially useful for whitelabelling - you can unpack, edit, and repack the JSON config without triggering a rebuild.
-
Create an
appsettings.jsonfile in your project. -
Add the provider to your configuration builder:
var config = new ConfigurationBuilder().AddJsonPlatformBundle().Build();You can also pass an environment name to enable environment-specific overrides:
var config = new ConfigurationBuilder().AddJsonPlatformBundle("DEBUG").Build();
Platform File Merge Priority
Section titled “Platform File Merge Priority”The provider automatically looks for platform-specific appsettings files and merges them with the base appsettings.json. The naming convention is:
appsettings.[platform].[environment].jsonWhere [platform] can be: ios, maccatalyst, apple (both iOS & Mac Catalyst), or android.
iOS / Mac Catalyst
Section titled “iOS / Mac Catalyst”Files are merged in this priority (highest to lowest):
appsettings.ios.[environment].json(ormaccatalyst)appsettings.ios.json(ormaccatalyst)appsettings.apple.[environment].jsonappsettings.apple.jsonappsettings.[environment].jsonappsettings.json
Android
Section titled “Android”Files are merged in this priority (highest to lowest):
appsettings.android.[environment].jsonappsettings.android.jsonappsettings.[environment].jsonappsettings.json
If any file does not exist, it is simply skipped.
Project File Setup
Section titled “Project File Setup”Ensure your project file includes the appropriate build actions for your config files:
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'"> <AndroidAsset Include="appsettings.json" /> <AndroidAsset Include="appsettings.android.json" Condition="Exists('appsettings.android.json')" /></ItemGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' Or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'"> <BundleResource Include="appsettings.json" /> <BundleResource Include="appsettings.apple.json" Condition="Exists('appsettings.apple.json')" /></ItemGroup>