Search code examples
buildwixnantwix3.9

Change Wix Product version number using NANT XmlPoke


I ran into this issue recently - when I try to replace the Wix Product version number using NANT XMLPOKE task, it returns the following error message "No matching nodes found".

<xmlpoke file="..\Setup\abc.wxs" xpath="//Wix/Product[@Version]" value="${version.label}" >

Initially I thought that this was an issue with XPATH statement that I wrote. So I kept trying with different XPATH (like \Wix) and I kept getting the same message back.

Understood from a blog that this is happening due to the namespace definition with the WiX element. Please find below the solution, in case someone doesn't find the blog.


Solution

  • The issue happens because of the namespace definition within the Wix element. You have to add the below changes to get the XMLPOKE working:

    <xmlpoke file="..\Setup\abc.wxs" xpath="//wx:Wix/wx:Product/@Version" value="${version.label}" >
          <namespaces>
            <namespace prefix="wx" uri="http://schemas.microsoft.com/wix/2006/wi" />
          </namespaces>
        </xmlpoke>
    

    Reference: Soledad Pano's blog