My product.wxs is like below
<?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" />
<ComponentGroupRef Id='svcComponents' />
</Feature>
<UI>
<UIRef Id="WixUI_InstallDir" />
</UI>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<Property Id="INSTALLFOLDER" Secure="yes" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="FileDeletionRecordService" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id='svcComponents' Directory="INSTALLFOLDER">
<Component Id="svcInstallation" Guid="{05F58B9B-BC8F-44BD-A4D1-DB4B8F824111}">
<File Id="FileDeletionRecordServiceEXE" Source="[INSTALLFOLDER]FileDeletionRecordService.exe" />
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Name="FileDeletionRecordService"
DisplayName="FileDeletionRecordService"
Description="Record file deletion for specified directory"
Start="auto"
Account="NT AUTHORITYLocalService"
ErrorControl="normal"
/>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="FileDeletionRecordService" Wait="yes" />
</Component>
<Component Id="cmpEventLog" Guid="{D15001E4-24F7-407E-977B-47A1B1F0B4B4}" KeyPath="yes" >
<Util:EventSource
Name="FileDeletionRecordSource"
Log="FileDeletionRecordService"
EventMessageFile="%SystemRoot%Microsoft.NETFrameworkv2.0.50727EventLogMessages.dll" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
In above I use UIRef
WixUI_InstallDir
to get value for INSTALLFOLDER
.
And I use it for the windows service exe that I would like to install
<File Id="FileDeletionRecordServiceEXE" Source="[INSTALLFOLDER]FileDeletionRecordService.exe" />
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Name="FileDeletionRecordService"
DisplayName="FileDeletionRecordService"
Description="Record file deletion for specified directory"
Start="auto"
Account="NT AUTHORITYLocalService"
ErrorControl="normal"
/>
But it shows
The system cannot find the file
‘[INSTALLFOLDER]FileDeletionRecordService.exe’.
Error when I was trying to build the project.
The part confuse me is, of course the file should not exist yet cause it has not been installed yet. But I need to install service from ‘[INSTALLFOLDER]FileDeletionRecordService.exe’ for sure.
Does that mean I should create the directories, move the files and install the service manually first so to create the setup pack? Is this the practice? Cause I feel it doesn’t make sense I think there are some usages I misunderstood but not sure what I did wrong.