I am currently writing a WiX installer, and the software that is generated leaves the mex endpoint line in the .exe.config, this is fine on development/debug systems, but for production it needs to be removed.
I have had no success so far in trying to remove this entry from the .exe.config using multiple methods (first using util:XmlConfig
and now with util:XmlFile
) hopefully someone here will have used this and have a bit more experience as I have spent too long on this now (embarassingly nearly 2 days..).
The XML .exe.config (redacted):
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="MainServiceBehaviour"
name="MyService">
<endpoint address="net.tcp://localhost:1111/endpoint" binding="netTcpBinding"
bindingConfiguration="netTcp" contract="project.ServiceInterface"/>
<endpoint address="net.tcp://localhost:1111/endpoint/mex"
binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:1111/endpoint"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
The WiX section trying to delete the second endpoint:
<Component Id="RemoveMexEndpoint" Directory="" Guid="*" KeyPath="yes">
<util:XmlFile Id="RemoveMexEndpointEntry"
Action="deleteValue"
Name="endpoint"
ElementPath="//configuration/system.serviceModel/services/service[\[]@behaviorConfiguration='MainServiceBehaviour'[\]]/endpoint[\[]@address='net.tcp://localhost:1111/endpoint/mex'[\]]"
File="[#MyExeConfig]"
PreserveModifiedDate="yes"
SelectionLanguage="XPath" />
</Component>
I originally was trying the WiX section with endpoint[\[]contains(@address,"mex")[\]]
as I didnt want to have a hard dependency on the endpoint address in the installer if avoidable.
As mentioned, I do not really know what to try next as I think I have exhausted all options and no StackOverflow post seems to work:
- Deleting XML element with XmlConfig extension in WIX using XPath
- https://blogs.technet.microsoft.com/alexshev/2009/05/27/from-msi-to-wix-part-25-installable-items-updating-xml-files-using-xmlfile/
- Deleting XML elements in WiX
EDIT/UPDATE:
The XmlConfig that I tried as mentioned in comments
<util:XmlConfig Id="RemoveMexEndpoint"
On="install"
Action="delete"
File="[#MyExeConfig]"
Node="element"
VerifyPath="//configuration/system.serviceModel/services/service[\[]@behaviorConfiguration='MainServiceBehaviour'[\]]/endpoint[\[]@address='net.tcp://localhost:8111/endpoint/mex'[\]]"
ElementPath="//configuration/system.serviceModel/services/service[\[]@behaviorConfiguration='MainServiceBehaviour'[\]]"
PreserveModifiedDate="yes" />
All I am able to see in the logs is that the "ExecXmlConfig" runs before the files are copied, not after. And that the return value is 1.. no logging of errors at all.