MSDeploy to install windows service?
Asked Answered
B

3

24

We have a website which publishes events using NServiceBus. The site is deployed using msdeploy. We also have the NServiceBus.exe which should run as a windows service to subscribe to these events, and we'd like to deploy that as well.

Is there any way to package the service as well as the website, so that it can be installed as well? Is it possible to package separately so we can deploy it to another server?

Any tips on where to find information on how to do this would be great, as we can do automated deployments for the website now.

Beghard answered 29/10, 2010 at 20:26 Comment(3)
I'd be very interested in what solution you came to on this.Jaddan
Unfortunately we ran out of time to find a solution, but I hope to be returning to this topic again soon.Beghard
I've finally posted a blog post on how we ended up doing this: jamescrowley.co.uk/2011/09/05/…Jaddan
T
5

I recently did this using MSDeploy, Phantom and installUtil.exe

You just basically need to modify your installer class and elevate your remote wmsvc service privileges if needed.

Link to blog

Tremendous answered 13/3, 2011 at 5:19 Comment(0)
S
4

What we wound up doing was creating a 'controller' layer that coordinates deployment tasks, even one that could use msdeploy. Essentially, msdeploy is not the highest level of abstraction in our deployment system.

We chose to use MSBuild to coordinate those tasks of deploying items from a 'package'.

In our deployment process, a web application deployed with msdeploy is just another deployment item, just as is a Windows service.

In all disclosure, we have not actually created msdeploy deployment tasks yet, though it should/would drop in nicely to what we've already created, as MSBuild would invoke the msdeploy. We currently use MSBuild community tasks for webapp deployment automation, coordinated via MSBuild.

You can read a little more about how we 'generalized' our deployments via a blog post I did called "PANDA - Packaging ANd Deployment Automation".

Scheme answered 16/11, 2010 at 13:33 Comment(2)
did you ever open sourced your PANDA stuff?Inarch
No, but thank you for the interest! At this point in time, think there are available alternatives (even on Windows) to fill that space (chef, PowerShell DSC, Octopus Deploy), etc.Scheme
T
4

Here is a msdeploy cmd line I used to sync an archivedir that is created from a post-build step in my Windows Service.proj file.

It is syncing from my build server to my app server on a different network. I have pre and post build steps that start and stop the services on the remote server. You must wrap the powershell script in a vb script due to a bug with powershell and msdeploy. The -verbose option is very helpful.

I also have the vbscript and ps1 script below. Be careful with the VB sleep and the pre and post msdeploy timeouts.

msdeploy -verb:sync -source:archivedir=\\qa-xxxxx1.qa.lan\deployment\backups\FreddieMacDelivery\FreddieMacDelivery.zip,tempAgent='True',computerName=qa-xxxxx1.qa.lan,userName=QA\xxxxx,password=xxxx,authtype=NTLM,includeAcls='False' -dest:dirpath=\\qa-xxxxxx1.qa.lan\protk\Services\FreddieMacDelivery\1.4.1.test -useCheckSum -verbose -preSync:runCommand="cscript.exe c:\temp\stop_win_svc.vbs" -postSync:runCommand="c:\temp\start_win_svc.vbs",waitInterval=15000,waitAttempts=1

VB script:

Option Explicit
Dim oShell, appCmd,oShellExec
Set oShell = CreateObject("WScript.Shell")

appCmd = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ""&c:/temp/Get_Win_SVC.ps1"" "

Set oShellExec = oShell.Exec(appCmd)

WScript.Sleep 1000
oShellExec.StdIn.Close()

Powershell script:

$username = 'QA\xxxxx'
$password = 'xxxxx'
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

(Get-WmiObject  -computer qa-xxxx1.qa.lan  -Credential $cred Win32_Service -Filter "Name='ProTeck.FreddieMac.DeliveryService'")


$svc = (Get-WmiObject  -computer qa-xxxxx1.qa.lan  -Credential $cred Win32_Service -Filter "Name='ProTeck.FreddieMac.DeliveryService'") 

Write-Host  $svc

$svc.InvokeMethod("StartService", $null)


(Get-WmiObject  -computer qa-xxxxx1.qa.lan  -Credential $cred Win32_Service -Filter "Name='ProTeck.FreddieMac.DeliveryService'")> c:\temp\win_stat_post.txt
Tiresome answered 9/9, 2011 at 14:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.