Yeah, the NAnt script would use the <exec> task to call the program with the
argument specifying what environment it was building from. So in Ant terms:
<for list="dev,qa,uat,prod" param="environment">
<exec dir="." executable="configure.exe">
<arg line="@{environment}"/>
</exec>
<now configs are set correctly so you stage it for deploy and package it
for that environment using your favorite installation tool/>
</for>
________________________________
From: nagish <[email protected]>
To: [email protected]
Sent: Wednesday, May 13, 2009 12:54:43 PM
Subject: Re: Merge base settings with environment specific ones
Thanks Eric. If I understood you correctly, it's that program you wrote that
did the trick for you, not the NAnt script. Is it correct? Thanks.
Eric Fetzer wrote:
>
> OK, so here's what I did with NAnt and a C# .Net project for this same
> problem. My properties files were all xml, so I wrote a program that read
> a master config file and based on what argument was passed for
> <environment>, the program went into the config file it was configuring at
> the designated xpath and set that node value to the specified
> environmental value. So the master config file looked something like
> this:
>
> <xml...>
> <configfile file="C:\program files\myfile.xml">
> <xpath
> value="configuration/appSettings/k...@key="connectionString"]/@value">
> <environments>
> <env dev="myConnectionStringForDev"/>
> <env qa="myConnectionStringForQA"/>
> <env prod="myConnectionStringForProd"/>
> </environments>
> </xpath>
> <xpath value="configuration/appSettings/k...@key="dogHouse"]/@value">
> <environments>
> <env dev="devDogHouse"/>
> <env qa="qaDogHouse"/>
> <env prod="prodDogHouse"/>
> </environments>
> </xpath>
> </configfile>
> <configfile file="C:\program files\anotherConfigfile.xml">
> <xpath
> value="configuration/appSettings/k...@key="connectionString"]/@value">
> <environments>
> <env dev="myConnectionStringForDev"/>
> <env qa="myConnectionStringForQA"/>
> <env prod="myConnectionStringForProd"/>
> </environments>
> </xpath>
> <xpath value="configuration/appSettings/k...@key="dogHouse"]/@value">
> <environments>
> <env dev="devDogHouse"/>
> <env qa="qaDogHouse"/>
> <env prod="prodDogHouse"/>
> </environments>
> </xpath>
> </configfile>
> </xml...>
>
> Seems something similar could be done for non-xml files as well using
> global substitution using regex or such...
>
--
View this message in context:
http://www.nabble.com/Merge-base-settings-with-environment-specific-ones-tp23524997p23527870.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]