Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I usually use straight powershell or msbuild for this. I try to avoid the flaky msdeploy. In msbuild you can use the very handy msbuild extension pack thus, so assuming you can copy files to your target destination (Robocopy is handy for that) this will do the rest:</p> <pre><code>&lt;Project ToolsVersion="4.0" DefaultTargets="InstallService" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt; &lt;UsingTask AssemblyFile="..\packages\MSBuild.Extension.Pack.1.2.0\lib\net40\MSBuild.ExtensionPack.dll" TaskName="MSBuild.ExtensionPack.Computer.WindowsService"/&gt; &lt;PropertyGroup&gt; &lt;MachineName Condition="$(MachineName)==''"&gt;&lt;/MachineName&gt; &lt;ServiceName Condition="$(ServiceName)==''"&gt;&lt;/ServiceName&gt; &lt;ServicePath Condition="$(ServicePath)==''"&gt;&lt;/ServicePath&gt; &lt;User Condition="$(User)==''"&gt;&lt;/User&gt; &lt;Password Condition="$(Password)==''"&gt;&lt;/Password&gt; &lt;SuppressStart Condition="$(SuppressStart)==''"&gt;&lt;/SuppressStart&gt; &lt;/PropertyGroup&gt; &lt;Target Name="CheckProperties" BeforeTargets="StopService"&gt; &lt;Message Text="MachineName: $(MachineName)"/&gt; &lt;Message Text="ServiceName: $(ServiceName)"/&gt; &lt;Message Text="ServicePath: $(ServicePath)"/&gt; &lt;Message Text="User : $(User)"/&gt; &lt;Message Text="SuppressStart : $(SuppressStart)"/&gt; &lt;/Target&gt; &lt;Target Name="StopService" BeforeTargets="InstallService"&gt; &lt;MSBuild.ExtensionPack.Computer.WindowsService TaskAction="CheckExists" ServiceName="$(ServiceName)" MachineName="$(MachineName)"&gt; &lt;Output TaskParameter="Exists" PropertyName="DoesExist"/&gt; &lt;/MSBuild.ExtensionPack.Computer.WindowsService&gt; &lt;MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Stop" ServiceName="$(ServiceName)" MachineName="$(MachineName)" Condition="$(DoesExist)=='True'"&gt; &lt;/MSBuild.ExtensionPack.Computer.WindowsService&gt; &lt;/Target&gt; &lt;Target Name="StartService" AfterTargets="InstallService"&gt; &lt;MSBuild.ExtensionPack.Computer.WindowsService TaskAction="CheckExists" ServiceName="$(ServiceName)" MachineName="$(MachineName)"&gt; &lt;Output TaskParameter="Exists" PropertyName="DoesExist"/&gt; &lt;/MSBuild.ExtensionPack.Computer.WindowsService&gt; &lt;MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Start" ServiceName="$(ServiceName)" MachineName="$(MachineName)" Condition="$(DoesExist)=='True' And $(SuppressStart)=='False'" RetryAttempts="20"&gt; &lt;/MSBuild.ExtensionPack.Computer.WindowsService&gt; &lt;Message Text="Service $(ServiceName) set not to start" Condition="$(SuppressStart)=='True'" Importance="High" /&gt; &lt;/Target&gt; &lt;Target Name="InstallService"&gt; &lt;PropertyGroup&gt; &lt;ServiceExeExists Condition="Exists('$(ServicePath)')"&gt;True&lt;/ServiceExeExists&gt; &lt;/PropertyGroup&gt; &lt;Message Text="Installing $(ServicePath) %(ServiceName.Identity)" Importance="high"/&gt; &lt;MSBuild.ExtensionPack.Computer.WindowsService TaskAction="CheckExists" ServiceName="$(ServiceName)" MachineName="$(MachineName)"&gt; &lt;Output TaskParameter="Exists" PropertyName="DoesExist"/&gt; &lt;/MSBuild.ExtensionPack.Computer.WindowsService&gt; &lt;Message Text="Installed $(ServiceName) $(ServicePath) for $(User) and $(Password)" Importance="high"/&gt; &lt;MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Install" ServiceName="$(ServiceName)" User="$(User)" Password="$(Password)" ServicePath="$(ServicePath)" MachineName="$(MachineName)" Condition="!$(DoesExist)"/&gt; &lt;MSBuild.ExtensionPack.Computer.WindowsService TaskAction="SetAutomatic" ServiceName="$(ServiceName)" MachineName="$(MachineName)" Condition="!$(DoesExist)"/&gt; &lt;Warning Text="%(ServiceName.Identity) service already exists" Condition="$(DoesExist)"/&gt; &lt;/Target&gt; &lt;/Project&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload