Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manage multiple app config files during development

I'm building an application that is used by several different customers. Each customer has a fair amount of custom business logic, which I have cleverly refactored out into an assembly that gets loaded at runtime. The name of that assembly, along with a number of other customer-specific settings, are stored in the application's configuration file.

Right now, here's what I have to do in order to debug the application for customer foo:

  1. Go to the filesystem in my project directory and delete app.config
  2. Copy app.config.foo to app.config.foo - Copy.
  3. Rename app.config.foo - Copy as app.config.
  4. Tell Windows that yes, I want to change the file's extension.
  5. Switch back to Visual Studio.
  6. Open the Settings.settings item in my project.
  7. Click "Yes" 13 or 14 times as VS asks me if I want to use the new settings that have been changed in app.config.
  8. Close Settings.settings.

Okay! Now I'm ready to debug!

It seems to me that the rigamarole of opening Settings.settings is, or ought to be, unnecessary: I don't need the default values in Settings.cs to be regenerated, because I don't use them. But it's the only way I know of to make VS aware of the fact that the app.config file has changed, so that the build will copy it to the output directory.

There's got to be an easier way of doing this. What is it?

like image 254
Robert Rossney Avatar asked Oct 06 '08 20:10

Robert Rossney


2 Answers

You can also let Visual Studio automate Robert`s approach by:

  1. Define a Build Configuration for each client
  2. In the post build event, simply xcopy app.config.xxx to your bin folder. Where XXX is the name of a Build Config accessible in VS. Something like: xcopy app.config.$(ConfigurationName) $(OutDir)/app.config

VS will drop a distinct build for your clients in separate folders, aolong with the proper config file. bin/Client1/ bin/Client2/

like image 146
magravelle Avatar answered Oct 27 '22 11:10

magravelle


You can refer this post for some good practices : Managing Multiple Configuration File Environments with Pre-Build Events

like image 3
Gulzar Nazim Avatar answered Oct 27 '22 09:10

Gulzar Nazim