views:

573

answers:

4

Fresh Asking of 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"&gt;

  <?--... 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 the SDC tasks can't seem to reference any of the xml nodes that are WIX related. For example:

<XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs"
         XPath="//iis:WebApplication" Namespaces="@(Namespaces)" 
         Name="Name" Value="$(VersionTag)"/>

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 (/Wix/Product/iis:WebApplication) the task returns: Could not find resource string No matches found for XPath expression

This is not a problem till I want to reference a Directory node (/Wix/Product/Directory/Directory/Directory/Directory[@Id='STWebSiteDir'])

I have tried using the full XPath and the shorter //Directory[@Id='STWebSiteDir']. I have tried single quotes and double quotes, I have tried adding the WIX namespace to the call (with no prefix).

<ItemGroup>
  <Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension"&gt;
    <Prefix>iis</Prefix>
    <Uri>http://schemas.microsoft.com/wix/IIsExtension&lt;/Uri&gt;
  </Namespaces>
  <Namespaces Include="http://schemas.microsoft.com/wix/2006/wi"&gt;
    <Prefix></Prefix>
    <Uri>http://schemas.microsoft.com/wix/2006/wi&lt;/Uri&gt;
  </Namespaces>
</ItemGroup>

I have even tried to just get a reference to /Wix/Product and even that fails:

<XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs" 
            XPath="/Wix/Product" Namespaces="@(Namespaces)" 
            Name="Name" Value="MODIFIED"/>

I am clearly missing something. Anyone with a hint on where to go to get this to work?

Vaccano

+1  A: 

Have you included the Wix default namespace in @(Namespaces)?

David McEwing
I must not understand you because I have the WIx namepace there in my question!!!!!
Vaccano
I don't have enough points or I would have voted you down.
Vaccano
So the solution you have below is what I was attempting to say. Default is different to Empty.
David McEwing
True enough. Voted you up instead.
Vaccano
A: 

OK, so here is the answer:

The namespace prefix needed to be missing for the wix part, not just left empty

<ItemGroup>
  <Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension"&gt;
    <Prefix>iis</Prefix>
    <Uri>http://schemas.microsoft.com/wix/IIsExtension&lt;/Uri&gt;
  </Namespaces>
  <Namespaces Include="http://schemas.microsoft.com/wix/2006/wi"&gt;

    <Uri>http://schemas.microsoft.com/wix/2006/wi&lt;/Uri&gt;
  </Namespaces>
</ItemGroup>

And then you need to add a prefix value to the wix namespace in the file. I used tst.

Vaccano

Vaccano
A: 

So the above does not work... The reason why is that WIX will not let you add a prefix to the namespace.

Back To the drawing board....

This is SO Frustrating!!!!

Vaccano
+2  A: 

Can you just define the variables on the command line to the preprocessor?

candle -dVariableName=ValueForVariable

That might be much easier.

Rob Mensching