HOW TO UPDATE A BUILD FILE using c#

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
TONYTHEKING
Posts: 2
Joined: Wed Jan 12, 2011 10:40 am

HOW TO UPDATE A BUILD FILE using c#

Post by TONYTHEKING » Wed Jan 12, 2011 11:02 am

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!

jclausius
Posts: 3702
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

Re: HOW TO UPDATE A BUILD FILE using c#

Post by jclausius » Wed Jan 12, 2011 11:58 am

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?
Jeff Clausius
SourceGear

TONYTHEKING
Posts: 2
Joined: Wed Jan 12, 2011 10:40 am

Re: HOW TO UPDATE A BUILD FILE using c#

Post by TONYTHEKING » Wed Jan 12, 2011 12:09 pm

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!

jclausius
Posts: 3702
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

Re: HOW TO UPDATE A BUILD FILE using c#

Post by jclausius » Wed Jan 12, 2011 12:49 pm

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.
Jeff Clausius
SourceGear

Post Reply