Specify the application base path in ConfigurationBuilder in beta8

后端 未结 1 964
一生所求
一生所求 2020-12-03 21:43

I used to specify the application base path for the ConfigurationBuilder like this:

public Startup(IApplicationEnvironment appEnv)
{
    var co         


        
相关标签:
1条回答
  • 2020-12-03 22:13

    If we look at the source code of ConfigurationBuilder, we can see that the constructor no longer accepts a string representing the application base path. In stead, we have to use the SetBasePath() extension method on the IConfigurationBuilder interface to specify it:

    public Startup(IApplicationEnvironment appEnv)
    {
        var configurationBuilder = new ConfigurationBuilder()
            .SetBasePath(appEnv.ApplicationBasePath)
            .AddJsonFile("config.json")
            .AddEnvironmentVariables();
    
        Configuration = configurationBuilder.Build();
    }
    

    The particular commit can be found here.

    0 讨论(0)
提交回复
热议问题