Tuesday, March 15, 2011

XPaths and <? ?>

I have a WIX file that I need to modify using MSBuild. It starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">

  <?--... Removed Params ...-->

  <?define ProductVersion = "1.0.1"?>

  <?--... Removed Params ...-->

  <Product Id='$(var.ProductCode)'
    UpgradeCode='$(var.UpgradeCode)'
    Name='$(var.AppName)' Language="1033" Version='$(var.ProductVersion)'
    Manufacturer='$(var.Manufacturer)'>
    <Package Id='$(var.PackageCode)' InstallerVersion="200" 
    Compressed="yes" />

  <?--... Rest of the WIX XML file ...-->

My problem is that I don't know what the XPath would to the <?define ProductVersion = "1.0.1"?> would be. Is there a way to reference that via XPath so I can use the SDC SetValue MSBuild Task to change it? It is not a node (I think) so I am not sure how to reference it.

Vaccano

From stackoverflow
  • It looks like /Wix/processing-instruction('define') may work for an XPath (whether or not MSBuild recognizes that, I don't know).

    By plugging that into SketchPath, I was able to click around in it and test various XPaths to see what would select that element.

  • //processing-instruction('define')

  • <?define> is a processing instruction node, so you should be able to address it using an XPath expression such as

    //processing-instruction('define')
    
  • Another approach would be to define the parameter via the command-line to candle:

    candle -dProductVersion=1.0.1
    

0 comments:

Post a Comment