Hitesh Singh
Hitesh Singh

Reputation: 19

How to override the server with now installer in visual studio installer 2015

I need to override the older version of installer form newer version.I am using installer for installing the windows services. Visual Studio Installer 2015.

I change the installer with property "RemovePreviousVersion"= true, But in the installer getting error because service is not uninstalled and try to override this.

Error 1001. An exception occurred in the OnAfterInstall event handler of System.ServiceProcess.ServiceInstaller --CouslNot Star service on computer

enter image description here

Upvotes: 1

Views: 119

Answers (1)

Stein Åsmul
Stein Åsmul

Reputation: 42236

Short Answer / Suggestion: Services must be stopped before install / uninstall / upgrade operations. There are mechanisms built into MSI to do so. Hotlink to show how this is done using WiX (ServiceInstall and ServiceControl elements).

Here is a proposed WiX quick start (with lots of link noise to all kinds of WiX and MSI topics - it is an ad-hoc organically growing link answer).


WiX: Use a proper deployment tool is the best advice, for example WiX. Visual Studio installer projects are known to be inflexible and have limitations for service installation among many other problems (shorter, list form).

Specifically in this case you need to use custom actions to start and stop services (unless there are new constructs in the latest Visual Studio installer projects that I am not familiar with - I don't think there are). Custom actions are complex and error prone. Proper MSI tools use built-in MSI constructs to make service installation more reliable.

Post-Processing: Some people post-process their MSI using Orca or equivalent tools to add constructs to the ServiceInstall, ServiceControl tables after building the MSIs with Visual Studio Installer Projects. Not rocket science, but a hassle and not recommended.

ServiceInstall & ServiceControl: Essentially you need to author the ServiceInstall and ServiceControl tables so that the service is installed, started, stopped and uninstalled in an operational manner. Only a few combinations here really make sense. Such as to stop on uninstall and stop and start on install.

WiX Samples: WiX quick start suggestions here and some WiX samples of service installation:


Advanced Installer: And two links for commercial tool Advanced Installer on service installations. Don't underestimate commercial tools as relevant for you. "Some tools are free only if your time is worthless". WiX is great, but can be hard to learn and always takes time:

Upvotes: 1

Related Questions