Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/refractalize/confgen
A tool to refactor your web.configs by
https://github.com/refractalize/confgen
Last synced: about 1 month ago
JSON representation
A tool to refactor your web.configs by
- Host: GitHub
- URL: https://github.com/refractalize/confgen
- Owner: refractalize
- Created: 2011-07-04T08:26:30.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-03-14T14:30:36.000Z (almost 12 years ago)
- Last Synced: 2024-11-08T16:18:54.364Z (about 2 months ago)
- Language: C#
- Homepage:
- Size: 332 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# confgen - a tool for streamlining your web.configs
ASP.net web sites usually have a web.config, if you stage deployments for the various environments, for development, system testing, user acceptance testing and then finally a live release, you'll probably have lots of web.configs, one for each staging environment. This tool ensures that you'll only ever keep one web.config, a master version, and generate the other web.configs from it.
The master config will be named web.master.config, and will (for the most part) be identical to any other web.config file, all the regular configuration elements, all familiar stuff. In fact, it just needs to have an extension of .master.config, so app.master.config will do too. The master file will contain some additional XML attributes to tell confgen which elements to include for which environments. The first of these is the "environments" attribute, containing a comma delimited list of environments to generate for, something like "dev,systest,uat,live". The "for" attribute is placed on all the elements that are different for each environment, and contains another comma delimited list of environments for which that element is to be included. If there is no "for" attribute, it's included for all environments.
## An example would be helpful...
web.master.config:
...
...
Will produce...
web.config (this is dev, a special case):
...
...
web.systest.config:
...
...
web.uat.config:
...
...
web.live.config:
...
...
You apply the "for" attribute to elements, so you could apply it to whole sections of your web.config, replacing an entire log4net section for example.
To install, just copy the exe into the folder where your web.configs are usually kept. When you change your web.master.config, run confgen (you can just double click it in explorer) and it will generate all your web.configs. Errors are printed to the console so if you're having trouble, launch it from cmd.## Variables
To set a variable:
value
To set a variable for a specific environment:
value
To use a variable, enclose the variable name in braces:
Also works for text inside elements:
net.msmq://{host}/myqueue
The conf:with-vars attribute controls whether to do variable substitution at all. The default is NOT to do substitution so existing braces won't break, making congen 2 fully backwards compatible with congen 1.
So by default:
Still generates:
The conf:with-vars attribute is inherited by sub-elements. Variables are inherited by sub-elements too.
So in the end, configurations like the one following should be much easier to read and write:
localhost
systest1
systest2
uatmachine
livemachine2
livemachine1