title: How do I use WiX to install PeterKottas.DotNetCore.WindowsService?
body: <p>I have built a windows service in DotNet Core that is installed with the Peter Kottas WindowsServer nuget (<a href="https://github.com/PeterKottas/DotNetCore.WindowsService" rel="nofollow noreferrer">https://github.com/PeterKottas/DotNetCore.WindowsService</a>). 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"</p>
  
  <pre><code>&lt;CustomAction Id="CallCmd" Value="[SystemFolder]cmd.exe" Directory="MYSERVICE" /&gt;
  &lt;CustomAction Id="MoveDirectory" Directory="MYSERVICE" ExeCommand="cd C:\Program Files (x86)\MYCOMPANY\MYSERVICE"/&gt;
  &lt;CustomAction Id="CA_InstallMyService" Directory="MYSERVICE" ExeCommand="MyService action:install" /&gt;
  
  &lt;InstallExecuteSequence&gt;
    &lt;Custom Action="CallCmd" After="PublishProduct" /&gt;
    &lt;Custom Action="MoveDirectory" After="CallCmd" /&gt;
    &lt;Custom Action="CA_InstallMyService" After="MoveDirectory" /&gt;
  &lt;/InstallExecuteSequence&gt;
  </code></pre>
  
  <p>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.</p>
  
  <p><a href="https://i.stack.imgur.com/QG0S0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QG0S0.png" alt="enter image description here"></a></p>
  
  <p>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.</p>
  
  <p>A little digging around in the event viewer shows this error:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>