I'm trying to install multiple windows services with the same executable, but WiX doesn't like the same name attributes in the two file tags. I have tried changing the names of the two file tags. It works but I hope I don't have to install two of the same executable just for that purpose. Is there a better way to do this? Here's my code so far:
<Component Id="Service1" Guid="{SOMEGUID1}">
<File Id='Service1' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe' KeyPath='yes'/>
<ServiceInstall
Id="ServiceInstaller1"
Type="ownProcess"
Name="MyService1"
DisplayName="MyService1"
Description="Some Description"
Start="auto"
Account="[SERVICEACCOUNT]"
Password="[SERVICEPASSWORD]"
ErrorControl="normal"
Arguments=' "Service1"'
Vital="yes"
Interactive="no" />
<ServiceControl Id="ServiceControl1" Stop="uninstall" Remove="uninstall" Name="MyService1" Wait="yes" />
</Component>
<Component Id="Service2" Guid="{SOMEGUID2}">
<File Id='Service2' Name='ConnDriver.exe' DiskId='1' Source='..\Service\obj\x86\$(var.BUILD)\ConnDriver.exe' KeyPath='yes'/>
<ServiceInstall
Id="ServiceInstaller2"
Type="ownProcess"
Name="MyService2"
DisplayName="MyService2"
Description="Some Description"
Start="auto"
Account="[SERVICEACCOUNT]"
Password="[SERVICEPASSWORD]"
ErrorControl="normal"
Arguments=' "Service2"'
Vital="yes"
Interactive="no" />
<ServiceControl Id="ServiceControl2" Stop="uninstall" Remove="uninstall" Name="MyService2" Wait="yes" />
</Component>
In features:
<Feature Id="Feature1" Title="Feature 2" Level="1" Description="...">
<ComponentRef Id="Service1_xml"/>
<ComponentRef Id="Service1"/>
</Feature>
<Feature Id="Feature2" Title="Feature 2" Level="1" Description="...">
<ComponentRef Id="Service2_xml"/>
<ComponentRef Id="Service2"/>
</Feature>
Any help is appreciated.
(PS. The reason I brake them up into 2 components is so that I can include an xml config file with the service in the features section. My windows service installer takes in a command line argument to know which xml file to read from and configure accordingly)
EDIT:
Error Output:
ICE30: The target file 'hlo8twix.exe|ConnDriver.exe' is installed in '[ProgramFilesFolder]\CompanyName\ProgramName\' by two different components on an LFN system: 'Service1' and 'Service2'. This breaks component reference counting.
In one of my projects, I have 2 services inside of one executable. So for both services in my exe, I have the following in my wix setup. Hope this helps.
A component can belong to more than one feature. Create a single component for your service, then multiple features: each feature has a
ComponentRef
to the one service component and whatever other references it needs.Finally found the solution. for multple services in same exe, you have to set Type="shareProcess" in ServiceInstall element and both the services will work just fine. I found this out by installing my service using "InstallUtil" and compared the registry structure. "InstallUtil" set type to ownProcess, so i changed mine in installer too and that worked like a charm.