I want to create custom NANT files. To do this, I use C# to create a “.build” file using the input from the user, I wish to create a custom build. I already have a build file, but each time I’m making a new project I have to create a new build file, so I would like only to input some information into a C# form and then the file would be auto-generated.
I tried with XmlTextWriter witch works fine for the header of my build file, but I get problems when I get to line like this :
<property name= "name" value = "test"/> .
With XmlTextWriter line are like this :
<description>This is a test.</description> .
So I wonder how could I write my NANT script.
It doesn’t have to be with XmlTextWrite …
- EDIT –
I found a way:
textWriter.WriteRaw("<property name = \"project.name\" value=\"" + projectName + "\" />");
result :
<property name = "project.name" value="test" />
I have to enter it “raw”, but it’s better than nothing. I’m still open to a better way to do it!
Thanks!
I highly recommend against handcrafting your own XML through a non-XML specific text writer. This will cause pain with escaping characters, among other things.
I might be missing something, but you should be able to use
XmlTextWriterfor this. This is untested but you should get the general idea: