开发者

MSBuild's XmlMassUpdate task in NAnt?

I have created an MSBuild tasks for building my projects, but for various re开发者_运维问答asons 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...


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


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>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜