Great idea. It would also be useful for updating assembly versions within
daily builds. And because it's very easy to use regular expressions on .NET
I suggest that we supported regexes in search patterns.

This way you could have:

<replace regex="^[assembly: AssemblyVersion(.*)]$" replace="[assembly:
AssemblyVersion(&quot;${project.version}&quot;)">
    <files>
        <includes name="**/AssemblyInfo.cs" />
    </files>
</replace>

I'm also thinking about using this task to insert / ensure standard license
header (BSD, GPL) into source files, but perhaps that should be another
task.

Jarek

----- Original Message ----- 
From: "Daya Sharma" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 19, 2003 7:30 PM
Subject: [Nant-users] Replace Task in Nant


> Hi All
>
> I think it will be wonderful to have a Replace task in Nant, much like it
is
> in ANT http://ant.apache.org/manual/CoreTasks/replace.html .
>
> This is specially useful for cases like changing the value of the project
> URL when using Solution task. Case in point is the following that I had to
> write to change "http://localhost/ipm/ipm.csproj"; project URL to
> <build.dir>/ipm/ipm.csproj in order for my .csproj to compile using NANT's
> solution task. (Pardon me for a pathetic algorithm of deleting and
> recreating the ipm.sln file.)
>
> public static void ScriptMain(Project project)
> {
> FileInfo fileInfo = new FileInfo(project.BaseDirectory + "\\ipm.sln");
> FileStream file = File.Open(fileInfo.ToString(), FileMode.Open,
> FileAccess.ReadWrite);
> StreamReader reader = new StreamReader(file);
> string line = null;
> line = reader.ReadToEnd();
> if(line.IndexOf("http://localhost/ipm";) != -1)
> {
> //Console.WriteLine(line);
> StringBuilder sb = new StringBuilder(line);
> sb.Replace("http://localhost/ipm/";, project.BaseDirectory+"\\");
> line = sb.ToString();
> reader.Close();
> fileInfo.Delete();
> Console.WriteLine(line); // output the changed file contents just for
> verbosity
> file = File.Open(project.BaseDirectory+"\\ipm.sln", FileMode.CreateNew,
> FileAccess.Write);
> StreamWriter writer = new StreamWriter(file);
> writer.AutoFlush = true;
> writer.WriteLine(line);
> }
> file.Close();
> }
>
> Please provide me with your input.
>
> Thanks in advance.
>
> -daya
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by Dice.com.
> Did you know that Dice has over 25,000 tech jobs available today? From
> careers in IT to Engineering to Tech Sales, Dice has tech jobs from the
> best hiring companies. http://www.dice.com/index.epl?rel_code=104
> _______________________________________________
> Nant-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/nant-users
>



-------------------------------------------------------
This SF.net email is sponsored by Dice.com.
Did you know that Dice has over 25,000 tech jobs available today? From
careers in IT to Engineering to Tech Sales, Dice has tech jobs from the
best hiring companies. http://www.dice.com/index.epl?rel_code=104
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to