XPath in MSBuild (SDC) and WIX
Fresh question about this question →
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">
<?--... Various 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" />
<?--... More of the WIX XML file ...-->
<iis:WebApplication Id='STWebApp' Name='MyWebSite' Isolation='medium' />
<?--... Rest of the WIX XML file ...-->
My problem is SDC tasks cannot reference any of the WIX related xml nodes. For example:
<XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs"
XPath="//iis:WebApplication" Namespaces="@(Namespaces)"
Name="Name" Value="$(VersionTag)"/>
works just fine because it doesn't use any Wix nodes (iis one only), but if I use the full XPath path to it (/ Wix / Product / iis: WebApplication) the task returns: Could not find resource string No matches found for XPath expressions
This is not a problem as long as I don't want to reference the node directory (/ Wix / Product / Directory / Directory / Directory / Directory [@Id = 'STWebSiteDir])
I've tried using the full XPath and the shorter // Directory [@Id = 'STWebSiteDir]. I've tried single quotes and double quotes, I've tried adding the WIX namespace to the call (no prefix).
<ItemGroup>
<Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension">
<Prefix>iis</Prefix>
<Uri>http://schemas.microsoft.com/wix/IIsExtension</Uri>
</Namespaces>
<Namespaces Include="http://schemas.microsoft.com/wix/2006/wi">
<Prefix></Prefix>
<Uri>http://schemas.microsoft.com/wix/2006/wi</Uri>
</Namespaces>
</ItemGroup>
I even tried to just get the link to / Wix / Product and even that failed:
<XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs"
XPath="/Wix/Product" Namespaces="@(Namespaces)"
Name="Name" Value="MODIFIED"/>
I am clearly missing something. Anyone with a hint of where to go to get this to work?
Vaccano
source to share
<ItemGroup>
<Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension">
<Prefix>iis</Prefix>
<Uri>http://schemas.microsoft.com/wix/IIsExtension</Uri>
</Namespaces>
<Namespaces Include="http://schemas.microsoft.com/wix/2006/wi">
<Prefix>wis</Prefix>
<Uri>http://schemas.microsoft.com/wix/2006/wi</Uri>
</Namespaces>
</ItemGroup>
you should also add a prefix for the wi namespace, after which it can ok, i checked it.
source to share
OK, so here's the answer:
The namespace prefix must be missing for the wix part, not just empty
<ItemGroup>
<Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension">
<Prefix>iis</Prefix>
<Uri>http://schemas.microsoft.com/wix/IIsExtension</Uri>
</Namespaces>
<Namespaces Include="http://schemas.microsoft.com/wix/2006/wi">
<Uri>http://schemas.microsoft.com/wix/2006/wi</Uri>
</Namespaces>
</ItemGroup>
And then you need to add the prefix value to the wix namespace in the file. I used tst.
Vaccano
source to share