3

I am currently looking at ways to manage app.config files. I currently have multiple version of same software running in different environments, where each software use specific version of app.config file. Users often make mistakes while they make configuration changes and it is hard to validate whether the current configuration file is correct for the specific version of software. When software is updated, the user(who might not be aware of every configuration changes in the new version of software) manually edits the app.config files. I am sure there might be better practices, but I am stuck with using app.config files/manual editing for now (feel free to share better methods for configuration handling however, for future reference)

My plan is to design a tool to automatically create app.config xml schema files for each software version (using XSD.exe), and detect possible mistakes/errors in user's configuration file (or perhaps try to suggest correct values). When that is in place, I'm looking to implement wizards to help users update/install new versions of software.

My question is, is there any already existing tools that does similar job? My google fu does not yield any results; Or, is there a better way of approaching this?

J.L
  • 147
  • 1
  • 3
  • 11
  • Why is attempting to validate/fix the config file easier to implement than adding a proper settings window in the first place (with built-in validation of values before they get written)? – AJ. Oct 03 '12 at 18:19
  • 1
    I think this question/answer will help you. http://stackoverflow.com/questions/3004210/app-config-transformation-for-projects-which-are-not-web-projects-in-visual-stud – Glenn Ferrie Oct 03 '12 at 18:21
  • Aj//Long story. GlennFerriveLive//Thanks! – J.L Oct 03 '12 at 19:02

1 Answers1

1

I think you should look at configuration transformations. The basic idea is to define different solution configurations for each permutation of the configuration data and then at build/deploy time, automagically inject the right value for the context of your deployment.

This is most commonly used for environment segregation i.e. DEV, TEST, PROD. In a web application you would define a solution configuration for each environment and then add a config transform for each configuration which means you would go from having a single web.config to having a web.DEV.config, a web.TEST.config and a web.PROD.config

Now I know that you are not working on a web application so the configuration transformation tooling shipped natively as part of Visual Studio won't work.

However there is a fabulous extension called SlowCheetah which brings the power of configuration transformations to any type of configuration.

http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5

syneptody
  • 1,250
  • 1
  • 10
  • 27
  • You can also manually get transformations working on non-ASP .NET projects by messing around a bit with the msbuild of the project file. Note that transformations will take place whenever you build though, rather than just when doing a publish. – Isaac Abraham Oct 03 '12 at 21:34
  • Thanks, I will definitely look into this! – J.L Oct 04 '12 at 21:17