I added code ref to this stackoverflow post. Below is my Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="FileDeletionRecordServiceSetup" Language="1033" Version="1.0.0.0" Manufacturer="HP GIS" UpgradeCode="7ec63c63-ad12-4cc7-bf7e-138caa10380f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="FileDeletionRecordServiceSetup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<UI>
<UIRef Id="WixUI_InstallDir" />
</UI>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="FileDeletionRecordService" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<Component Id="svcInstallation" Directory="INSTALLFOLDER">
<File Id="FileDeletionRecordServiceEXE" Source="FileDeletionRecordService.exe" KeyPath="yes"/>
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Name="FileDeletionRecordService"
DisplayName="FileDeletionRecordService"
Description="Record file deletion for specified directory"
Start="auto"
Account="NT AUTHORITY\LocalService"
ErrorControl="normal"
/>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="FileDeletionRecordService" Wait="yes" />
</Component>
</Fragment>
<Fragment>
<Component Id="cmpEventLog" Directory="INSTALLFOLDER">
<Util:EventSource
Name="FileDeletionRecordSource"
Log="FileDeletionRecordService"
EventMessageFile="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll" />
</Component>
</Fragment>
</Wix>
It installed the content to the directory but not installed as windows service (no service entry is added to Services panel)
I tried msiexec /i FileDeletionRecordServiceSetup.msi /l*v install.log
to see if there is anything odd but doesn't seem any error or message related. Not sure if it's since I'm not familiar with this so don't know what should I look for. (The log is too long to attach so not going to include it here)
I think my wix version is 3.1 (In wixproj, the project version is 3.1)
From the snippet you provided, nothing is referencing the svcInstallation
Component's Fragment. Therefore, the linker elides the code in that fragment.
Assuming the service and the event registration go together, I'd merge the last two fragments like this:
<Fragment>
<ComponentGroup Id='svcComponents' Directory="INSTALLFOLDER">
<Component Id="svcInstallation">
<File Id="FileDeletionRecordServiceEXE" Source="FileDeletionRecordService.exe" />
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Name="FileDeletionRecordService"
DisplayName="FileDeletionRecordService"
Description="Record file deletion for specified directory"
Start="auto"
Account="NT AUTHORITY\LocalService"
ErrorControl="normal"
/>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="FileDeletionRecordService" Wait="yes" />
</Component>
<Component Id="cmpEventLog">
<Util:EventSource
Name="FileDeletionRecordSource"
Log="FileDeletionRecordService"
EventMessageFile="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll" />
</Component>
</ComponentGroup>
</Fragment>
And in the Feature
add:
<ComponentGroupRef Id='svcComponents' />