Hey Alessandro,
Are you talking about modifying existing versions in your wyBuild project, or are you talking about an example to generate the xml file?
I'm trying to automate the application build and I need to update the newversion,xml file using nant.I'm trying to change the Version node, the Changes node and the File source node.Do you have an example on how to do this?
ThanksAlessandro
Hey Alessandro,
Are you talking about modifying existing versions in your wyBuild project, or are you talking about an example to generate the xml file?
Yes. I would need to generate, using nant, e file like this:
<?xml version="1.0" encoding="utf-8"?><Versions> <AddVersion> <Version>0.12.7.0</Version> <Changes>New update system</Changes> <InheritPrevRegistry /> <Files dir="basedir"> <File source="D:\Progetti\My\dyemrp\build_0.12.7.0\*" /> </Files>
<Files dir="commappdata"> <File source="D:\Progetti\My\dyemrp\checkdb.tx" /> </Files> </AddVersion></Versions>
or better using variable replacement
<?xml version="1.0" encoding="utf-8"?><Versions> <AddVersion> <Version>${ver]</Version> <Changes>${changes}</Changes> <InheritPrevRegistry /> <Files dir="basedir"> <File source="D:\Progetti\My\dyemrp\build_${ver}\*" /> </Files>
<Files dir="commappdata"> <File source="D:\Progetti\My\dyemrp\checkdb.tx" /> </Files> </AddVersion></Versions>
thanks for the quick answer, I'd like to complete the test before the end of April to, eventually, purchase.
I see. Well, you can do this a few ways. Probably the easiest way is to use the nant build task "exec" and use a quick and dirty script or program to generate the XML file.
For example, here's a snippet that will work in C#:
XmlTextWriter writer = new XmlTextWriter("newversion.xml", null);
//Write the root elementwriter.WriteStartElement("Versions");writer.WriteStartElement("AddVersion");
writer.WriteElementString("Version", "1.1");writer.WriteElementString("Changes", "The Times They Are a-Changin'");writer.WriteElementString("InheritPrevRegistry", "");
writer.WriteStartElement("Files");writer.WriteAttributeString("dir", "basedir");foreach (string file in Files) // where Files is a string array or list{ writer.WriteElementString("File", file);}writer.WriteEndElement(); // </Files>
writer.WriteEndElement(); // </AddVersion>writer.WriteEndElement(); // </Versions>
//Write the XML to file and close the writerwriter.Close();
You can customize this simple console program to accept arguments like you were saying to target particular build folders, etc.
Then, after this console app generates the XML file, use the wyBuild arguments to add the new version to your wyBuild project.
Does this help?
Ok. I'll try your example.
In the meantime I tried to use xmlpoke but without success, probably because I don't know very well how to use it.see below. <xmlpoke file="D:\Progetti\My\dyemrp\Setup\wyUpdate\NewVersion.xml" xpath="/Versions/AddVersion/@Version" value="${app.ver}" /> <xmlpoke file="D:\Progetti\My\dyemrp\Setup\wyUpdate\NewVersion.xml" xpath="/Versions/AddVersion/Changes/" value="New update system" /> <xmlpoke file="D:\Progetti\My\dyemrp\Setup\wyUpdate\NewVersion.xml" xpath="/Versions/AddVersion/Files/File/source" value="${out.dir}" />
this snippet return error "node not found" on the first xmlpoke.
ThanksAlessandro
I don't have a lot of experience with NAant, but I believe XML poke is just for modifying existing XML files. That's why I suggested throwing together a quick program to generate the XML file for you. This method has the added advantage of being faster and you have more control over the output.