I don't think so. I had a similar problem and had to resort to a custom
script. It's not that difficult though, something along the following
lines would do it:
<snip>
<?xml version="1.0"?>
<project name="example" default="update-file">
<property name="db.user" value="sa" />
<target name="update-file">
<script language="c#">
<code><![CDATA[
public static void ScriptMain(Project project)
{
string srcDir = Path.Combine(project.BaseDirectory, "web");
string outDir = Path.Combine(project.BaseDirectory, "build");
string dbuser = project.Properties["db.user"];
string srcFile = Path.Combine(srcDir, "web.config");
using (StreamReader reader = File.OpenText(srcFile))
{
string contents = reader.ReadToEnd();
contents = contents.Replace("DBUSER", dbuser);
string outFile = Path.Combine(outDir, "web.config");
using (StreamWriter writer = new StreamWriter(outFile))
{
writer.Write(contents);
}
}
}
]]>
</code>
</script>
</target>
</project>
</snip>
Best wishes,
Rodrigo
----- Original Message -----
From: "Shiv Natarajan" <shiv_natarajan@...>
To: <nant-users@...>
Sent: Saturday, December 20, 2003 5:24 AM
Subject: [Nant-users] Find and Replace task
> Is there a 'find and replace in text file' task in
> nant.
>
> Basically, I want to have pre-defined strings in my
> web.config file and would like to replace it with
> actual values as part of 'deploy' target.
>
> eg.
> // web.config
> key="db.user" value="DBUSER"
>
> // release.xml
> <property name="db.user" value="sa"/>
> <target name="deploy">
> <find-and-replace
> findString="DBUSER"
> replaceWith="${db.user}"
> ignoreCase="false"
> matchWholeWord="true"/>
> </target>
>
> TIA.
> - shiv
|