UppercuT - Automated Builds - ConfigBuilder

UppercuT comes with ConfigBuilder.  What is ConfigBuilder? ConfigBuilder will build a configuration file per environment so you no longer have to maintain a bunch of configuration files.

In any project you have app.config (or web.config) files. You just create a .template file next to it. The web.config has a file next to it named web.config.template. What do you name the app.config template files? You have to name the file based on what app.config becomes when visual studio builds the application.

1. First you need to find out what the application configuration is going to be called when it is built. This is typically the dll or exe name with .config at the end. In the example below it is AutoTest.Console.exe.config.

 Showing AutoTest.Console.exe.config

2. Then in your solution find the App.config file. Right click and select [Copy].

 Solution Explorer in Visual Studio outlining App.config Copy App.config

3. Paste it back into the project. Right click on the project and select [Paste].

 Paste App.config back into your project

4. Rename the file to the same as you found the output file to be, but with .template after it. In our case this would be AutoTest.Console.exe.config.template.

 Copy of App.config

 AutoTest.Console.exe.config.template

5. Click {Yes} on the warning by Visual Studio.

 Change file extension. Click Yes

6. Right click on the new template file and select [Properties].

 Properties of AutoTest.Console.exe.config.template

7. In the properties dialog and make the following edits:

    a. [Build Action] should be Content.

    b. [Copy to Output Directory] should be Copy always or Copy if newer.

 Properties of .template file BEFORE

 Properties of .template file AFTER

8. Now open the *.template file. Make edits to replace values with values that change in each environment. You do this by inserting a reference to a variable, “${variableName}”. In the example below, I am replacing my log4Net logging level with a variable I can change across environments. This is so I can have DEBUG on in DEV, but possibly as high as WARNING or ERROR in PROD.

    a. You may have noticed that Windsor Castle Service locators look identical. Leave those as they are. We will discuss how to keep them there as they are later.

 Updating template file BEFORE

 Updating Template file AFTER

9. Follow the above steps for every configuration file you might have (including other XML files).

10. In the Settings folder, create ENVIRONMENT.settings files.

 Folder with Environment.settings files

11. In each file there is a property defined to replace properties referenced in the *.template file(s).

 Environment.settings file

12. If you use Windsor Castle Service Locators, you will want to replace them with themselves. You do that by setting the value to “${‘${castleServiceLocator}’}”.

 Castle service locators are themselves

13. When you run build.bat the next time, you are going to see messages like this. One per environment and each template file.

 Text of Build.bat showing configbuilder in action

14. In the code_drop folder, you notice that now you have a Configurations folder.

 A Configurations folder is built

15. In the Configurations folder, the number of files here is determined by the number of ENVIRONMENT.settings files times the number of *.template files.

 Configurations folder with all of the configurations that have been built by UppercuT

With this knowledge, you shall build.

kick it on DotNetKicks.com

Print | posted @ Sunday, May 17, 2009 10:15 PM

Comments on this entry:

Comments are closed.

Comments have been closed on this topic.