I've been writing a WIX 3 installer for a Windows Service with 2 self hosted WCF services. In order to connect to the WCF services, a Namespace reservation must be made using netsh.exe. I wanted to get the WIX installer to perform this operation during installation so decided to use a CustomAction to achieve this. As anybody who uses WIX will know, it is extremely powerful but sparsely documented and quiet frustrating to use. It took a while to get the CustomAction to work, so I thought I'd share the solution:
!-- Custom action to set WCF namespace reservation -->
<CustomAction Id="ListenerServiceAddReservation"
Directory="INSTALLLOCATION"
ExeCommand="[SystemFolder]netsh.exe http add urlacl url=http://+:8888/ServiceNamespace/TestService/ sddl=D:(A;;GX;;;WD)"
Return="asyncWait" />
<CustomAction Id="ListenerServiceDeleteReservation"
Directory="INSTALLLOCATION"
ExeCommand="[SystemFolder]netsh.exe http delete urlacl url=http://+:8888/ ServiceNamespace/TestService/"
Return="asyncWait" />
<InstallExecuteSequence>
<Custom Action="ListenerServiceDeleteReservation" Before="InstallFinalize">Installed</Custom>
<Custom Action="ListenerServiceAddReservation" Before="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
Thank you
ReplyDeleteI second this...
ReplyDeleteThank you!
Since adding urlacl requires administrative privilege, is it necessary to add Execute="deferred" to tag?
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteShawn is correct, you need execute=deffered for vista+, I was working ok XP when I wrote this
ReplyDeleteImpersonate should also be set to "no" for vista+
ReplyDeleteYou're a saint
ReplyDeleteThis is Awesome! I am not familiar with WIX but uses your code get my job done.
ReplyDeleteThanks Shawn and Geoff!
ReplyDelete