S.H.
S.H.

Reputation: 2853

C# How to create a Setup project for a Windows Service to install it automagically?

I have seen multiple Windows Services getting installed in my computer with just an Setup.exe or .msi... is it something special that it needs to be done with the setup project to let such Windows Services installed in a easy way without Installutil.exe?

I have tried and it just doesn't install the Service. I know how to use Installutil but that I would think it's just for testing. I need to be able to install my windows service with an Setup.exe because I want to distribute my Service with its configuration Tray app.

What would be the correct way to install the service and then my app? They both use a same DLL created in the same solution.

Problem while Building a Setup Project for a windows Service?

I looked at the link above but its about the Setup Project which I already know how to do, the problem is how to make my Setup project working... my DLL is getting up in place, the Tray app is working as well, the problem is the Service not getting installed it is just giving me the .exez

but I need it to be installed correctly like be up and running at reboot and in the Service Control Manager.

Upvotes: 4

Views: 21800

Answers (2)

fjsj
fjsj

Reputation: 11250

Here is a simple template for creating a *.msi installer for a Windows Service with WiX:

http://www.schiffhauer.com/wix-template-for-installing-a-windows-service/

I was able to specify my DLL dependencies with File tags.

Upvotes: 1

mynkow
mynkow

Reputation: 4558

Option 1
1. Download Wix
2. Download and install Wix Windows Service Setup Project Template
3. Create a new wix setup project and see what you get

This is the easiest way to create a *.msi without any option windows

Option 2
Follow this blog post. Same as option 1 but without the project template. If you go the WiX route sooner or later you will see that the project template provides basic stuff. If you want more advanced stuff you need to learn WiX a little bit and use its candle.exe, light.exe, pyro.exe etc.

Option 3
I wrote a short post how I usually do this.

Good luck

Upvotes: 10

Related Questions