I am building a .NET Framework WPF application, however, I want to use IConfigurationBuilder, which is a part of the newer (.NET Core and up) Microsoft.Extensions.Configuration namespace. My understanding is that .NET Framework apps traditionally use the app.config file in conjunction with ConfigurationManager class.
Unfortunately, I have to use .NET Framework. Despite this, I would strongly prefer IConfigurationBuilder as a) this is the more modern approach, b) it meshes well with adding services/DI (through Microsoft.Extensions.Hosting and the Host class), and c) it appears easier in numerous aspects than working with the older app.config setup, particularly when it comes to managing configurations for different environments.
I think I could keep app.config and still integrate with my Host setup by using the Microsoft.Extensions.Configuration.Xml NuGet (which has several AddXmlFile methods). I believe I could also just delete the app.config (and Settings.settings) and add an appsettings.json.
My question is: can I expect any issues with choosing appsettings.json over app.config in a .NET Framework application? I am curious if others have done this, and if so, why they did this. I welcome any advice or insight related to this.
ConfigurationBuilderorIConfigurationBuilderin your .Net Fw application? As you said, those classes are not part of the classic .NET framework - are you thinking of to backporting them?.exe.configis still used for purposes unrelated to your application's custom settings/config. The CLR will automatically try to locateMyProgram.exe.configfor these, and will expect the file to match the XML configuration schema. On the other hand,appSettings.jsonis far more loosely defined, and more importantly is unrelated to any .NET CLR feature, so it cannot replace exe.config for anything but your own custom config)..exe.configit's good to know about it. I see that when I do not have anapp.config, but rather anappsettings.json, building the project results in the.exe.configbutapp.configis not re-generated. Which is what I think you are saying and is ideal for my purposes - I ultimately would like to useappsettings.jsonand the associated, newer, libraries.appsettings.jsonand associated, newer, libraries, gives me more confidence about the application. Thank you @BenCottrell!