Reputation: 113
Error : Creating new installer using WiX toolset, for windows service. Not able to install the service. Getting an error
Error screenshot
I want to create a MSI which installs a Windows service.
Windows service gets installed and visible in services.msc
Stop and Remove the service.
My windows service has lot of dependencies which are to be used when running the service.
I have added all the files as component and added ServiceDependency
for each of the component ID also, but still not able to resolve the error. The error in the event viewer is also the same as the above screenshot.
Any pointers are most welcome.
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="LayoutSwitcher" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="LayoutSwitcher" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="PlcmLayoutSwitcherWinSvc.exe" Guid="PUT_GUID_HERE" KeyPath="yes">
<File Id="LayoutSwitcherWinSvc.exe"
Name="LayoutSwitcherWinSvc.exe" Source="$(var.LayoutSwitcherWinSvc_TargetDir)LayoutSwitcherWinSvc.exe" />
<CreateFolder />
<ServiceInstall Id="LayoutSwitcher" Type="ownProcess" Vital="yes"
Name="LayoutSwitcher" DisplayName="LayoutSwitcher"
Description="LayoutSwitcher" Start="auto" Account="NT AUTHORITY\LocalSystem"
ErrorControl="ignore" Interactive="no">
<ServiceControl Id="StartService" Start="install" Stop="both"
Remove="uninstall" Name="LayoutSwitcher" Wait="yes" />
</Component>
<Component Id="logoicon.ico" Guid="PUT_GUID_HERE">
<File Id="logoicon.ico" Name="logoicon.ico" Source="$(var.LayoutSwitcherWinSvc_ProjectDir)logoicon.ico" />
</Component>
<Component Id="LayoutSwitcherWinSvc.exe.config" Guid="PUT_GUID_HERE">
<File Id="LayoutSwitcherWinSvc.exe.config" Name="LayoutSwitcherWinSvc.exe.config" Source="$(var.LayoutSwitcherWinSvc_TargetDir)LayoutSwitcherWinSvc.exe.config" />
</Component>
<Component Id="Transactions.dll" Guid="PUT_GUID_HERE">
<File Id="Transactions.dll" Name="Transactions.dll" Source="$(var.LayoutSwitcherWinSvc_TargetDir)Transactions.dll" />
</Component>
<Component Id="Transactions.Cfg.dll" Guid="PUT_GUID_HERE">
<File Id=" Transactions.Cfg.dll" Name="Transactions.Cfg.dll" Source="$(var.LayoutSwitcherWinSvc_TargetDir) Transactions.Cfg.dll" />
</Component>
Updated the source code after removing the service dependency, but still getting the same error.
Removed the whitespaces, but still getting the same error.
Verbose logs attached. Please download from the below link.
http://www.yourfilelink.com/get.php?fid=1432133
Upvotes: 6
Views: 6390
Reputation: 1430
Can you try this piece of wix code? I cleaned it a little bit to remove some default values.
Unless you want to place the file with a different filename you don't need the Name attribute.
If you want your service to run as Local System then you need to set empty Account. If you want it to run as a specific user then you could set the properties on your command line SVCACCOUNT=someuser SVCPASSWORD="password", otherwise just skip them.
If Name and Id is the same then you can skip the Id.
I prefer to use variables for things that I use in multiple places to avoid typos, for example ServiceName that is used in ServiceInstall and ServiceControl I use:
<WixVariable Id="ServiceName" Value="LayoutSwitcher" />
<Component Id="PlcmLayoutSwitcherWinSvc.exe" Guid="PUT_GUID_HERE">
<File Id="LayoutSwitcherWinSvc.exe" Source="$(var.LayoutSwitcherWinSvc_TargetDir)LayoutSwitcherWinSvc.exe" KeyPath="yes" />
<ServiceInstall Name="!(wix.ServiceName)"
DisplayName="LayoutSwitcher"
Description="LayoutSwitcher"
ErrorControl="ignore"
Type="ownProcess"
Vital="yes"
Start="auto"
Account="[SVCACCOUNT]"
Password="[SVCPASSWORD]"
Interactive="no" />
<ServiceControl Id="ServiceControl_!(wix.ServiceName)"
Name="!(wix.ServiceName)"
Start="install"
Stop="both"
Remove="uninstall"
Wait="yes" />
</Component>
The log you attached is incomplete, run the installer all the way through and attach the log only after you've closed the installer. IMO Debug log is not necessary.
Upvotes: 6
Reputation: 20780
Your message:
"Failed to store ACL rollback information with error 0x80070424;Error 0x80070424: failed to get security info for object;CustomAction ExecSecureObjects returned actual error code 1603"
is nothing to do with the services. Ideally you should close this question because the service problem is resolved and you now have a separate problem, described by that error message.
Somehow you have managed to invoke a WiX custom action "ExecSecureObjects" that is nothing to do with your services. Somewhere in your WiX you are trying to secure some objects with the PermissionEx from the WiX util extension. That is the issue you are now seeing.
Upvotes: 3
Reputation: 15905
Your ServiceDepenency elements appear to be listing the dlls and other files that your service's executable depends on. That is not the intention of the ServiceDependency element. It is supposed to list other services that must start before this service. The error you receive is likely due to the fact that LayoutSwitcherWinSvc.exe.config and all the *.dll files you list others are not the names of services installed on the target machine.
The fix is likely to remove these ServiceDependency elements. Then, only if your service depends on other services, add ServiceDependency elements for those services by name.
With that part solved, it appears your ServiceInstall and ServiceControl elements are still incorrect. In particular, the Name attributes don't match. In your example code, it appears you include leading whitespace in a lot of your elements, and I would remove that. But, even if that's just errata from copy and paste, the installed LayoutSwitcher differs from started Layout Switcher by some whitespace in the middle.
This matches the error 0x80070424 you mentioned in the comment, as 0x424 = 1060, and net helpmsg 1060 reports:
The specified service does not exist as an installed service.
Make sure that the ServiceInstall/@Name and ServiceControl/@Name attributes match what you used when manually starting the service. (Note that if your manual test was on the command line, it is strongly likely that any whitespace was implicitly removed.)
Upvotes: 4
Reputation: 20780
Try making both of the Name attributes exactly the same in the install and the control. They need to match exactly and they don't. You're trying to start a non-existent service.
Upvotes: 4