Search code examples
c#-4.0windows-servicessetup-project

Setup Project - Allow multiple installation of the same Windows Service


I have a question regarding to Setup Projects in .Net (c# language, Framework 4.0):

I made a setup project for a Windows Service, on the installation wizard, the user must input the name of the Windows Service as it would be installed. The setup program also creates a shortcut to the Uninstall program in case the user wants to remove that Windows Service.

The question is: how to let the user run the same setup program several times specifing different service name? This behaviour could be required because the windows service is a socket consumer that connects to a server and retrieves data; to take advantage of the server capabilities the user could install the same windows service multiple times pointing to a different port on the server, to perform the data retrieving task much faster. The service is the same, the user just modify the port on the configuration file of the service, so that's why it's not logical to create a new version of the installer each time.

Any clue or suggestion would be appreciated, thanks in advance.


Solution

  • This can be done by using an multiple instances installation. The general approach is:

    • create a transform for each instance you want available to the user
    • use a custom EXE bootstrapper which applies a new transform to your MSI package each time a new instance is installed

    The transform should change at least the PackageCode, ProductCode and UpgradeCode.

    This is not supported by Visual Studio setup projects. So either you do it manually or use a commercial setup authoring tool which supports multiple instances.