c# - What is the best way of automating Windows Service deployment? -


i have created windows service using c# in visual studio 2010. did lot of research automating installation process. got lots of advice none did work me. windows service have created has lots of dependencies , client have no ui interaction during installation. have created setup project includes dependencies within installer.

process involved:

  • create build windows service
  • push setup file (.msi) remote location
  • call .msi , install service silently without user interaction.

what did far:

  • created powershell script push files remote location
  • execute powershell script , install service

please keep in mind powershell script

sc create "servicename" binpath="somepath" 

is used installing service project directory not installing .msi file created using setup project these 2 vast different things. if don't understand don't answer please.

possible solutions:

now question is. how can push windows service installer remote location? , how can create custom build arguments , use either msbuild extension pack or exec task , install service?

i know sounds stupid , irritating question hasn't installed service using (.msi) created setup project. requirements trying solve since weeks in enterprise environment.

i bulk of work powershell script.

  1. use msbuild exec task mentioned add build process. here's pretty article on using exec task run powershell script.

  2. since using vs 2010, setup , deployment project pretty easy. add 1 solution, , add output of service project it. here's article on adding setup project windows service.

  3. use powershell scripts copy installer .msi remote server. can use copy-item [source] [destination] if have access file share.

  4. stop service on remote machine. can use (get-service -computername [destination] -name [service-name]).stop() (from this question)

  5. install service silently using psexec psexec \\remotecomputer "[msi-destination-path]" /qn here's rest of command line options .msi.

  6. start service using (get-service -computername [destination] -name [service-name]).start()

i'd add bunch of parameters powershell script destination server, service name, etc. make maintaining part of build process easier. build agent have administrator on destination machine well.

lastly, make sure put powershell build script in source control!

edit (june 2014)
vs 2013 has installer projects again! (sorry, vs 2012)

also, if found this awesome answer how install windows service without using setup project.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -