Creating installers for your Windows Service applications with Visual Studio 2012

Posted: (EET/GMT+2)

 

One of the project's I'm currently working on requires a Windows Service application, and since I wanted to use the latest Visual Studio 2012 version for the project (along with .NET Framework 4.5), there's a quick tip to be shared.

If you look at the resources on the Internet about writing service applications with Visual Studio, you'll oftentimes find older information such as this CodeProject article from 2006. Although this information is still valid in Visual Studio 2012 for the most parts, this older information would generate more manual work for you than is necessary.

That is, in Visual Studio 2012, you can automatically generate installers for you – you don't need to manually generate these anymore.

This is how to do it: when you start your new service application project for .NET 4.5, you will be presented with a blank service application skeleton. Once you've created your actual service implementation, you will need an installer in your project so that InstallUtil can install your service to the target system.

To add the installer, simply open the (blank) designer view for your service (by default, Service1.cs) and right-click an empty spot. From the popup menu, select "Add Installer", and the code will be added for you. Simply customize the properties of the added components, and you are ready to go.

For more details, see the updated instructions for adding installers on MSDN.