I have built a windows service in DotNet Core that is installed with the Peter Kottas WindowsServer nuget (https://github.com/PeterKottas/DotNetCore.WindowsService). In order to install the service you have to publish the code, deploy it wherever, run cmd prompt with administrator rights, move directory to the deployed code and execute the following line: "MyService action:install"
<CustomAction Id="CallCmd" Value="[SystemFolder]cmd.exe" Directory="MYSERVICE" />
<CustomAction Id="MoveDirectory" Directory="MYSERVICE" ExeCommand="cd C:\Program Files (x86)\MYCOMPANY\MYSERVICE"/>
<CustomAction Id="CA_InstallMyService" Directory="MYSERVICE" ExeCommand="MyService action:install" />
<InstallExecuteSequence>
<Custom Action="CallCmd" After="PublishProduct" />
<Custom Action="MoveDirectory" After="CallCmd" />
<Custom Action="CA_InstallMyService" After="MoveDirectory" />
</InstallExecuteSequence>
Looking in Orca it appears to be sitting in the correct order, as these instructions can't browse to the folder until it has been created.
However, on executing the MSI and after clicking "Install" it gets halfway through, fails and runs backwards through the installation process. (I've tried watching the "Program Files (x86)" directory and do not even see my directory folder structure stated in my Product.wxs being created.
A little digging around in the event viewer shows this error:
Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: MoveDirectory, location: C:\WINDOWS\SysWOW64\cmd.exe\, command: cd C:\Program Files (x86)\MYCOMPANY\MYSERVICE