Page 1 of 1
HOW TO UPDATE A BUILD FILE using c#
Posted: Wed Jan 12, 2011 11:02 am
by TONYTHEKING
I need a c# program that opens up a NANT BUILD file, it then goes out and edits the following text in the file:
In the file I need to change db_server = "whatevervalue" to equeal db_server = ""
db_user = "whatevervalue" to db_user = ""
db_password = "whatevervalue" to db_password = ""
the above values exist in a nant build file that I need to modify so that another build file can change the values of the "whatevervalue" to equal somthing else when the build is executed. This needs to be done in a c# program
Thank You!
Re: HOW TO UPDATE A BUILD FILE using c#
Posted: Wed Jan 12, 2011 11:58 am
by jclausius
This is outside the scope of Vault, but could you use <replacestring> within a filterchain within a NAnt script to make the change to that second script?
Re: HOW TO UPDATE A BUILD FILE using c#
Posted: Wed Jan 12, 2011 12:09 pm
by TONYTHEKING
jclausius wrote:This is outside the scope of Vault, but could you use <replacestring> within a filterchain within a NAnt script to make the change to that second script?
I have done exactly this but the problem is that there is NO NANT way of removing the values inside of the quoted string because it could be anything such as: DB_SERVER = "SERVERNAME1" if i was to use the replacestring it would look like this:
<filterchain>
<replacestring from='db_server =' to='db_server = "${db.server}"' />
So with the above code your result would look like: db_server = "oldservername" "newservervalue"
and you can see that I ONLY want to change the value of "oldservername" the replacestring does replace the vaule but it needs to pad everthing to the RIGHT of the "servername1" with blank space (air) nothing blank
Thanks!
Re: HOW TO UPDATE A BUILD FILE using c#
Posted: Wed Jan 12, 2011 12:49 pm
by jclausius
Hmm... I don't know if you have control over this, but in Vault's build, we do things like code the following in some of the variable type files:
server='SSSSSSSSS'; PWD='PPPPPPPPP'
Then those strings are replaced during the build by NAnt.
Again, I don't know if you have control over those files in your situation, but if not, perhaps others can offer their solutions.