XmlFile TaskAction="RemoveElement" not working!

Oct 6, 2010 at 10:45 AM

Hi there,

I am attempting to use the XmlFile TaskAction "RemoveElement" to remove an element from an WXS (in XML format) file.

I have the following MSBuild task,

<Target Name="RemoveOptionalModules" > 

This seems to work when the test.xml file contain the elements from Feature and below, anything above this i.e. /Wix/Product doesn't appear to work.

Does anyone know why or have any ideas? Does the RemoveElement action support many levels of xml hierarchy?

PS. I've checked the XPath and is correct as far as I know. Also, I have tried using XPath = "//FeatureRef[@Id='ProductFeature_PrintedReportsUI']" which works too, if I only have the Feature element block in my test.xml file, anything above this doesn't appear to work.


Oct 6, 2010 at 12:56 PM

It appears it doesn't work when the root element contains:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
Is there any way around this?
Oct 6, 2010 at 1:17 PM

Yes, you need to pass in the namespace. See the online help for a sample which illustrates Namespace usage.


Oct 6, 2010 at 1:47 PM

Thanks Mike, I've just found that out now... :)

	<Namespaces Include="WixNamespace">
<Target Name="RemoveOptionalModules" >
        <MSBuild.ExtensionPack.Xml.XmlFile Namespaces="@(Namespaces)" TaskAction="RemoveElement"

It now works! :D