title: XPath in MSBuild (SDC) and WIX
body: <p>Fresh Asking of this Question-></p>
  
  <p>I have a WIX file that I need to modify using MSBuild.  It starts like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
       xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension"&gt;
  
    &lt;?--... Various Removed Params ...--&gt;
  
    &lt;Product Id='$(var.ProductCode)'
      UpgradeCode='$(var.UpgradeCode)'
      Name='$(var.AppName)' Language="1033" Version='$(var.ProductVersion)'
      Manufacturer='$(var.Manufacturer)'&gt;
      &lt;Package Id='$(var.PackageCode)' InstallerVersion="200" 
      Compressed="yes" /&gt;
  
    &lt;?--... More of the WIX XML file ...--&gt;
  
    &lt;iis:WebApplication Id='STWebApp' Name='MyWebSite' Isolation='medium' /&gt;
  
    &lt;?--... Rest of the WIX XML file ...--&gt;
  </code></pre>
  
  <p>My problem is the SDC tasks can't seem to reference any of the xml nodes that are WIX related.  For example:</p>
  
  <pre><code>&lt;XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs"
           XPath="//iis:WebApplication" Namespaces="@(Namespaces)" 
           Name="Name" Value="$(VersionTag)"/&gt;
  </code></pre>
  
  <p>works just fine because it does not use any Wix nodes (just an iis one), but if I use the full XPath path to it (<em>/Wix/Product/iis:WebApplication</em>) the task returns:
      <strong>Could not find resource string No matches found for XPath expression</strong></p>
  
  <p>This is not a problem till I want to reference a Directory node (/Wix/Product/Directory/Directory/Directory/Directory[@Id='STWebSiteDir'])</p>
  
  <p>I have tried using the full XPath and the shorter //Directory[@Id='STWebSiteDir'].  I have tried single quotes and double quotes, <strong>I have tried adding the WIX namespace to the call (with no prefix).</strong></p>
  
  <pre><code>&lt;ItemGroup&gt;
    &lt;Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension"&gt;
      &lt;Prefix&gt;iis&lt;/Prefix&gt;
      &lt;Uri&gt;http://schemas.microsoft.com/wix/IIsExtension&lt;/Uri&gt;
    &lt;/Namespaces&gt;
    &lt;Namespaces Include="http://schemas.microsoft.com/wix/2006/wi"&gt;
      &lt;Prefix&gt;&lt;/Prefix&gt;
      &lt;Uri&gt;http://schemas.microsoft.com/wix/2006/wi&lt;/Uri&gt;
    &lt;/Namespaces&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>I have even tried to just get a reference to /Wix/Product and even that fails:</p>
  
  <pre><code>&lt;XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs" 
              XPath="/Wix/Product" Namespaces="@(Namespaces)" 
              Name="Name" Value="MODIFIED"/&gt;
  </code></pre>
  
  <p>I am clearly missing something.  Anyone with a hint on where to go to get this to work?</p>
  
  <p>Vaccano</p>