Tagged with Configuration
As I've been teaching ASP.NET Core for a while now, some things I've been saying I've taken on faith. One of these was that building a Configuration Source (a provider that can read configuration and feed it into the configuration system) is fairly easy.
With a break in building my Vue course, I was curious so I decided to build a configuration source that I hope no one uses. It is a configuration source that reads the AppSettings in a web.config file. This is a thought exercise, not a recommendation.
In order to be a Configuration Source, you must derive from the IConfigurationSource interface. You could implement this interface directly, or if your configuration is file based (like the one I built), you can simply derive from FileConfigurationSource. This class deals with most of the problem of opening and reading a file. Since my Configuration Source is to read the web.config, that's perfect.
Everytime I add a app.config file to a new C# App, it never does what I want. I want the app.config file to be deployed to the build directory so I can make changes to the app.config file and have it propogated. With the release of VS.NET 2003, us C# developers now have pre and post build steps. So I now have to remember to add the following to the post-build event:
xcopy /s $(ProjectDir)app.config $(TargetPath).config
I know I could write an "Add New Item" to make it happen, but I just haven't had the time. I just wish MS had done it for me.
Chris Sells has alerted me to the fact that if your project has a app.config file, VS.NET 200X will copy it and rename it for you. My bad. I could have sworn that I tried this before and it didn't work : (