0

I was trying to follow this tutorial:

Which said:

"Click Setup and Deployment Projects under Project Types, and then click Setup Project under Templates."

But in my VS2012 - there is no Setup Project:

screenshot

So I am confused what to do?

ps. What is the easiest way to install a Windows service on a different computer? (I don't like the idea of using tool which has steep learning curve for this task).

pps. Can't I manually use installUtil to install the windows service say on the target machine? What are caveats with this approach??

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
  • why downvote? I showed what I did so far. And asked a clear question –  Jun 11 '15 at 09:36
  • possible duplicate of [Create MSI or setup Project with visual studio 2012](http://stackoverflow.com/questions/12378125/create-msi-or-setup-project-with-visual-studio-2012) – Micke Jun 11 '15 at 09:42
  • @Micke: That is not necessarily duplicate - there might be other ways to install service on different machine than using installer - that is what I also asked here; and that question is not about services –  Jun 11 '15 at 09:46
  • You might be correct, but have a look at the accepted answer anyway. It'll tell you that the limited installer cannot be used to install a service, and provides info on what to use instead. – Micke Jun 11 '15 at 09:48
  • @Micke: Ah so I can't use that installer to install a Windows Service? –  Jun 11 '15 at 09:49
  • Yes you can use installutil to install the service. If this is an in-house project it's the easiest way. – Stephen Kennedy Jun 13 '15 at 13:04

4 Answers4

0

Check out Visual Studio setup projects (vdproj) will not ship with future versions of VS.

WiX Toolset is a good alternative and has a quite steep learning curve. Checkout this sample.

Dolgsthrasir
  • 127
  • 9
Sameer
  • 3,124
  • 5
  • 30
  • 57
  • learning curve doesn't sound nice now-isn't there some easier alternative? maybe manually install the service on target machine? –  Jun 11 '15 at 09:53
0

I recently hit this issue as well. If you can get on the machine via remote desktop then you can run "InstallUtil" and point it at your service executable:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe c:\path\to\my\service.exe

If you can't remote into the machine then there are tools such as PsExec https://technet.microsoft.com/en-gb/sysinternals/bb897553.aspx which will allow you to run applications on remote machines. You might be able to use this to run InstallUtil on the remote server.

The method I used was to run "service controller" with something like this:

sc.exe \\myserver create "My Service Name" binpath= c:\path\to\my\service.exe

There's some more information on it here: https://technet.microsoft.com/en-us/library/cc990289.aspx There's also a bunch of flags you can use to set up all the parameters of a service e.g. what action to take if it stops.

Tasker
  • 186
  • 7
  • what about `installutil`? Can't I use that? It would be easier than using a tool I guess. What are caveats with `installutil`? –  Jun 11 '15 at 10:08
  • I think I got my answer wrong a little bit about installutil, you don't need a setup project for it, I think you can just point it at the service executable. I've updated my answer. – Tasker Jun 11 '15 at 10:43
  • are you suggesting something like in this answer? http://stackoverflow.com/questions/2599562/how-can-i-install-a-windows-service-onto-a-machine-that-doesnt-have-visual-stud. But must the target machine also have .net framework for this? and must the version of .net framework on the target machine match the .net framework version where the service was built? –  Jun 11 '15 at 10:48
  • Yes that looks basically the same as what I'm saying. The target machine will need the .net framework installed to do this (but then if your service uses .net then you'd need it just to run). You might be able to get away with using an older framework version of InstallUtil but you'd be best off using the latest/a version matching your assembly. – Tasker Jun 11 '15 at 10:52
  • Ok that seems only alternative now? The only trick is now whether those .net framework versions should match or not –  Jun 11 '15 at 11:18
  • Looks like this might be the answer you were looking for: http://stackoverflow.com/questions/14564467/can-installutil-be-used-to-install-a-service-written-with-a-newer-version-of-the – Tasker Jun 11 '15 at 11:19
  • So they say the versions must match? I will give a try anyway maybe I can get away with it; btw. is it lot of work to update newer version of .net framework on target machine? –  Jun 11 '15 at 11:23
  • It shouldn't be a lot of work. You should just be able to download and run the installers straight off e.g. https://www.microsoft.com/en-gb/download/details.aspx?id=30653 You might find you need to update "windows installer" or chain the updates e.g. install .Net 3, then .Net 4 then... but it's not complex or particularly time consuming. – Tasker Jun 11 '15 at 11:28
  • Maybe I can get away with older version of `installUtil` .. otherwise I need to update as I see.. there seems no other option? –  Jun 11 '15 at 11:36
  • Does Visual Studio need to be installed on target machine to use `installUtil` if you know? thanks –  Jun 11 '15 at 11:44
  • No I don't think you need VS. It should just come with the .NET framework. – Tasker Jun 11 '15 at 11:55
0

You can also use MsDeploy to deploy a windows service. We did it recently in our project, you can find a tutorial here.

Alioza
  • 1,690
  • 12
  • 14
0

If you have the time/scope, worth checking out Topshelf. It makes building and deploying Windows Services ridiculously easy, with no need for messy setup projects/installers. It just becomes a case of calling myservice.exe install or myservice.exe uninstall (plus any credentials if needed). This can be triggered remotely or as Tasker suggested, using sc or psexec.

  • what about the `installutil` tool? what are the caveats with it? –  Jun 11 '15 at 10:04
  • You won't need to use intallutil in that case, have a read of [this](http://topshelf.readthedocs.org/en/latest/overview/faq.html). – user4998653 Jun 11 '15 at 10:10
  • Yes but I have already created my service, this thing asks me to create a new service using TopShelf? –  Jun 11 '15 at 10:11
  • Why not use `installutil ` if it can solve my problem? Just I read somewhere some .Net framework versions must be same of installUtil and service that is what I am tryign to figure out now –  Jun 11 '15 at 10:11
  • Yes it should do the trick if this is a one-off install. Easiest to get the service files on the remote machine, then register the service with installutil or sc (just watch out for [caveats](http://stackoverflow.com/questions/4692250/installing-windows-service-with-sc-exe-or-installutil-exe-there-is-difference)). My answer may be of longer term help if a) maintenance and deployment of the service will be on-going and b) you have the time. Depending on complexity, the service logic should be very straightforward to port across. If so, IMO it's worth the effort if you can... – user4998653 Jun 11 '15 at 11:30
  • I think I can use `installUtil` just I think the .NET versions must match on target machine and where the service was built... I am figuring that out now –  Jun 11 '15 at 11:35