Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2013 Windows Service - How to make installer?

I have written a Windows Service.

I now want to package it up in an installer.

I have used the VS2013 x86 Native Tools Command Prompt and then used the commands:

To install it:

installutil httpapiservice.exe

To uninstall it:

installutil httpapiservice.exe /u

This works perfectly. I can see the new service in "Services" and stop and start it no problem.

I then proceeded to right click on the project and select "Publish" and it produced a setup.exe

But, when I run the setup.exe I can see it "downloading and extracting" the files. It looks like it's installing but nothing appears in "Services"

Can anyone tell me if I am doing it correctly please?

Thanks

like image 554
Trevor Daniel Avatar asked Apr 08 '14 13:04

Trevor Daniel


People also ask

How do I create an installer for Windows Service?

In Solution Explorer, access Design view for the service for which you want to add an installation component. Click the background of the designer to select the service itself, rather than any of its contents. With the designer in focus, right-click, and then click Add Installer.

How do I create a Windows installer in Visual Studio?

Go to Extensions > Manage Extensions > Online > Search, find, download and install Microsoft Visual Studio Installer Projects extension. 2). Add a new Setup Project in your solution > right-click Application Folder > Add > Project Output… > choose the corresponding Project > select Primary output > OK.

How do I get Visual Studio installer?

In the Windows Start menu, you can search for "installer", and then select Visual Studio Installer from the results. If you have Visual Studio open, select Tools > Get Tools and Features..., which opens the Visual Studio Installer.


4 Answers

You need to add a setup project to your solution to build an installer executable.

Unfortunately Microsoft removed their setup project template from Visual Studio 2012 onwards, which would have done the job.

This means you are stuck with one of the alternatives, which are either less functional, harder to set up, or expensive.

NOTE - scroll down to EDIT 3 for my recommended solution. The rest of this post is just to highlight alternatives.

If you fancy the free route you can add on InstallShield Limited Edition to Visual studio, and use it to create a setup project for your solution. It will work for windows service setup projects in the latest version, but is generally considered pretty rubbish and limited. Here's the instructions for this: link

WiX is a free open source alternative, which is far more functional, but tricky to set up.

EDIT -

Here's an article describing how to use WiX to create a setup project: http://www.schiffhauer.com/wix-template-for-installing-a-windows-service/

EDIT 2 -

As of today (22/04/2014) Microsoft have reinstated the setup project in Visual Studio 2013 as an Visual studio extension - see this post

I've not tried it myself, but it's presumably the same as the VS2010 setup project, which wasn't too hard to learn (and there's plenty of help available on the internet) I'd definately recommend you try this for creating your setup program!

EDIT 3 (Apr 2016) -
I'd highly recommend you use the Visual Studio Installer Projects Extension (as mentioned in the above edit) for creating simple installers for your windows services (and other programs too). The installers it creates are simple, but professional looking enough for simple or small projects.

The extension for Visual Studio 2013 is here
The extension for Visual Studio 2015 is here
The extension for Visual Studio 2017 is here

An article describing how to create a setup project for a windows service using the old VS2010 Setup project is here. Although this is an old article it can be applied directly to the new Installer Project extensions linked above. (Thanks EbbnFlow for the link)

like image 183
James S Avatar answered Sep 20 '22 12:09

James S


I recommend watching this video. https://www.youtube.com/watch?v=cp2aFNtcZfk

Tried and verified

like image 37
Ahmed IG Avatar answered Sep 18 '22 12:09

Ahmed IG


I ended up zipping up the software and including installutil.exe and simply gave the customer instructions have to install and uninstall.

Seems to have worked perfectly.

HTH

like image 27
Trevor Daniel Avatar answered Sep 20 '22 12:09

Trevor Daniel


It seems you want to use ClickOnce (publish) to install a service. This isn't possible without a hassle but you can try to do it as described in this answer.

like image 28
tobsen Avatar answered Sep 20 '22 12:09

tobsen