1
votes

I have created an MSBuild tasks for building my projects, but for various reasons I wan't to switch to NAnt.

Is there some task that would be equivalent to MSBuild's XmlMassUpdate in NAnt? If possible I would like to use the same xml replacement file I used with XmlMassUpdate.

(for more info about XmlMassUpdate, here's a short usage I found on stackoverflow's site: MSBuild example)

I tried with xmlPeek/xmlPoke tasks but couldn't get them to iterate a tree paths in a replacement file...

2

2 Answers

0
votes

It turned out that I just need to adjust the code from tigris' implementation into the one that would work for NAnt.

The solution is a bit lengthly so it doesn't make sense to post it here in whole, but these would be the steps...

Tigris MsBuildTasks site has both the binaries and the source code for every task.

Just find the implementation of XmlMassUpdate, see how it's done, and create NAnt task class in your task library, like so:

[TaskName("XmlMassUpdate")]
public class XmlMassUpdate : Task
{
    [TaskAttribute("ContentFile", Required=true)]
    public string ContentFile { get; set; }
    //...
    protected override void ExecuteTask()
    {
        // ...
    }
    //other methods
}

What's rest is to copy your library dll to nant's bin and you can use it... enjoy

0
votes

You can expand properties within a file when you copy it in Nant. Instead of having to write a different update for each property, you can create a template file with you nant vars inside it. ...

        <fileset basedir="${config.dir}\NantTemplates">
            <include name="**\*" />
            <exclude name="*.template"/>                
        </fileset>
        <filterchain>
            <expandproperties/>
        </filterchain>