Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

    Configuration = configurationBuilder.Build();
}

However, as of beta8, the constructor of ConfigurationBuilder does not take an application base path argument anymore and it throws an exception now.

How can I specify the base path?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
301 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...