0

I am trying to update a windows service coded in C#. In the installer, I've made sure to: - DetectNewerInstalledVersion : true - RemovePreviousVersions: true - Updated version in both the installer and the assembly file of the service itself.

I stop my running service before trying to reinstall it. Nonetheless, when I run the installer (or using the default installutil), it says "Error 1001. The specified service already exists." <-- Shouldn't it update it then (as specified in the install settings)?

** THE GOAL IS TO AVOID HAVING TO MANUALLY UNINSTALL THE SERVICE EACH TIME I MAKE A CHANGE TO ITS CODE **

Any help will be much appreciated!

gyslinn
  • 21
  • 3
  • This is the [best answer](http://stackoverflow.com/questions/7395609/what-is-the-best-way-to-auto-update-a-windows-application) so far. – gyslinn Jan 24 '17 at 17:00

1 Answers1

0

Using the native service installer is crap. to uninstall you need the original files in the original location.

Try nssm. https://nssm.cc/

Steve Coleman
  • 1,987
  • 2
  • 17
  • 28
  • Well, thanks, but I'm not trying to remove the service, just to update it. The original files are there, where I place them (C:Program Files/My folder/My service, thou, the installer nor the installutil does the updating. The goal is to avoid having to uninstall manually each time I need to update the so-called service. Any help will be much appreciated. – gyslinn Jan 23 '17 at 19:27
  • Updating an existing service in not necessary. Stop it and replace the files. as long as they are the same name it will be fine when you restart it. – Steve Coleman Jan 23 '17 at 19:31
  • How do you programmatically replace those files then? According to [this article](http://stackoverflow.com/questions/4069879/how-to-force-deployment-project-to-update-files-during-installation-of-newer-ver) and [this other article](http://stackoverflow.com/questions/3024753/installing-a-new-version-of-a-deployment-project-over-old-version), you need to update the version in both the assembly and the installer, and those files will be updated on reinstall.... but you're saying i have to manually replace them? – gyslinn Jan 23 '17 at 19:38
  • Everytime I create a service to update it. I just shut it down and replace the files. I don't use the installer. http://stackoverflow.com/questions/22162477/how-to-update-an-installed-windows-service – Steve Coleman Jan 23 '17 at 19:42
  • 4 an install project.. Maybe this will work. like i Said eariler. Service installer is crap. http://stackoverflow.com/questions/327895/upgrade-a-windows-service-without-uninstalling – Steve Coleman Jan 23 '17 at 19:43
  • A simple, Xcopy or anything you put into your installer to copy the files will work if the service is stopped. – Steve Coleman Jan 23 '17 at 19:44
  • This could work while running tests, but not in deployment. In other words: whenever I update to a new version of MS Office (for example), I never go to their install folder and erase-and-replace the files w the new ones! Nor any other software. So, how do they do that? – gyslinn Jan 23 '17 at 20:06