views:

4260

answers:

2

I've upgraded a [.vdproj MSI generator project built into VS2008] System.Configuration.Install.Installer with a ServiceProcessInstaller and a ServiceInstaller from Visual Studio 2005 to 2008. There are no customisations of consequence to the installer class (i.e., not trying to start or stop services or register children)

RemovePreviousVersions is set to true, and I'm changing the Version and ProductCode. This triggers an error during the install:

"error 1001: the specified service already exists"

Googling yields stuff (but not on SO until now):- Google for "The specified service already exists"
The most useful one I've seen to date is http://forums.msdn.microsoft.com/en-US/winformssetup/thread/b2d1bd22-8499-454e-9cec-1e42c03e2557/ however this doesn't answer the fundamental question:-

Given that the user can pick either:
a) an install location that's the same
or b) an install location that's different
what are the minimal code changes would one sensibly make to ensure that the old service gets uninstalled and the new one gets installed? Or is there something other than a code change required to resolve this for the basic scenario of upgrading v1.0.1 to v1.0.2 of the same service with the same name (i.e., signing)

(AIUI the strong naming only comes into play if one has a significant uninstall step in the old installer that you dont have in the new one.)

I generated a new installer in VS 2008 and it fares no better.

For now, my workaround is to stop updating the Version and ProductCode, forcing the user to manually uninstall when they are told they already have a version installed.

Addendum thanks to divo's probing: While the simplest hack that could possibly work is to say "if install step is called & its an upgrade, call the uninstall step for the service first", I'd like a proper officially blessed answer! (e.g., how does the simple hack cope when the service is being renamed during an upgrade?)

+1  A: 

Does your service (setup) provide a custom action for uninstalling the service?

An upgrade means that the previously installed product get uninstalled before the new product gets installed. I think the reason for the error is that the old service cannot be removed.

If your service is written in .NET you might find this article useful: http://www.codeproject.com/KB/install/InstallService.aspx

0xA3
No custom code whatsoever in the installer - its just an undulterated System.Configuration.Install.Installer with a ServiceProcessInstaller and a ServiceInstaller. Yes, it is .NET, have edited, thanks for the clarifying push!
Ruben Bartelink
Ruben Bartelink
Would that be the "official" answer? http://msdn.microsoft.com/en-us/library/aa367570(VS.85).aspx. Btw, with problems like these it might be helpful to create an MSI log: msiexec /i MyService.msi /l*vx log.txt
0xA3
Not sure what you're driving at with that answer - remember uninstall followed by install works - just upgrade fails. 2k5 used to do an uninstall followed by a reinstall, 2k8 muddies things by replacing some of the files and letting you "pick it out of that" to tidy the mess.
Ruben Bartelink
re logging, was aware of the logging possibility, but is really a WAD from the MS perspective - just that it doesnt work OOTB, so a workaround needs to be 'published' for this
Ruben Bartelink
+4  A: 

This should answer your question

http://stackoverflow.com/questions/451573/how-do-i-eliminate-the-specified-service-already-exists-when-i-install-new-versio/617385

Ryan
http://stackoverflow.com/questions/617409/script-to-change-action-sequence-records-in-an-msi/ answers it even more succinctly. Now if the dup of this question would go away!
Ruben Bartelink
Hi Ruben - I don't think the link you mentioned is a dup - there are several ways to get around the problem mentioned here, one of which is the script to change action sequences. That post doesn't explain the background to the problem, just one way to fix it.
Ryan