Posted By: Anonymous
How do I create an installer for a Windows Service that I have created using Visual Studio?
In the service project do the following:
- In the solution explorer double click your services .cs file. It should bring up a screen that is all gray and talks about dragging stuff from the toolbox.
- Then right click on the gray area and select add installer. This will add an installer project file to your project.
- Then you will have 2 components on the design view of the ProjectInstaller.cs (serviceProcessInstaller1 and serviceInstaller1). You should then setup the properties as you need such as service name and user that it should run as.
Now you need to make a setup project. The best thing to do is use the setup wizard.
Right click on your solution and add a new project: Add > New Project > Setup and Deployment Projects > Setup Wizard
a. This could vary slightly for different versions of Visual Studio.
b. Visual Studio 2010 it is located in: Install Templates > Other Project Types > Setup and Deployment > Visual Studio Installer
On the second step select "Create a Setup for a Windows Application."
On the 3rd step, select "Primary output from…"
Click through to Finish.
Next edit your installer to make sure the correct output is included.
- Right click on the setup project in your Solution Explorer.
- Select View > Custom Actions. (In VS2008 it might be View > Editor > Custom Actions)
- Right-click on the Install action in the Custom Actions tree and select ‘Add Custom Action…’
- In the "Select Item in Project" dialog, select Application Folder and click OK.
- Click OK to select "Primary output from…" option. A new node should be created.
- Repeat steps 4 – 5 for commit, rollback and uninstall actions.
You can edit the installer output name by right clicking the Installer project in your solution and select Properties. Change the ‘Output file name:’ to whatever you want. By selecting the installer project as well and looking at the properties windows, you can edit the
Next build your installer and it will produce an MSI and a setup.exe. Choose whichever you want to use to deploy your service.