Warren Buckley
09/21/2021, 12:00 PMusing Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
[assembly: HostingStartup(typeof(MyAwesomePackage.MyPackageConfig))]
namespace MyAwesomePackage
{
public class MyPackageConfig : IHostingStartup
{
public void Configure(IWebHostBuilder builder)
{
builder.ConfigureAppConfiguration((ctx, config) =>
{
var env = ctx.HostingEnvironment;
config.AddJsonFile("mypackage.json", optional: true, reloadOnChange: true)
.AddJsonFile($"mypackage.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
});
}
}
}
But the problem is that .NET does not auto scan all assemblies. You have to use/update ENV variable
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "MyAwesomePackage;"
Still poking around but not sure setting an ENV variable gonna be much nicer/friendlier than what we have.
Currently trying to see how/if other libraries use this approach