Recently my team was working on a task of Framework up-gradation from 2.0 to 4.0 during which they were struggling with upgrading of Dot Net Installers for some of the foundation softwares + SDK installers.
The anxiety was at its best when just before last day of my sprint I found some hint on one my favorite sites StackOverflow.
This is one reason which prompts me write/share/help people know some of the dark sides of Microsoft which they do behind the scenes. Yes time and again I am here with my experience of this very interesting problem.
The funny side of this problem is the tool i used for identifying and resolving this issue is a tool by Microsoft itself…Orca.exe.
Orca.exe is a database table editor for creating/editing/debugging Windows Installer packages.
Problem Statement:
Update an existing dot net installer created using VS2005 having custom Installer class used in custom actions which installs/uninstalls windows services. I would call this “Visual Studio 2005 -> 2008/10 Service Installer Project Upgrade issue“. This issue is not usually faced in web installers.
Every time we convert this installer project from Framework 2.0 to Framework 4.0 using VS2010 and run the compiled msi on a system with older version of this software to upgrade we get typical ERROR 1001 stating “The specified service already exists”. This is because the installer was not able to upgrade by removing the older version before installing the new one.
Here I would like to emphasis more on System Upgrade as we were not facing any issue on a fresh install. Generally, in order to make your msi up gradable we generally set the RemovePreviousVersions property of the installer to True and change the GUID and Assembly Version so that msi can auto detect for the system upgrade. Perhaps this behavior FAILS when we compile installer projects in VS2008 or above.
Solution:
If you have set both install and uninstall custom actions in an application’s setup project, and you have enabled the RemovePreviousVersions property in Visual Studio 2005, the previous version of the product is uninstalled during an upgrade. However, this behavior changed in Visual Studio 2008 as follows:
In Visual Studio 2005, the custom actions were called as follows on an upgrade from v1.0.0 to v1.0.1: v1.0.0 custom action Uninstall() v1.0.1 custom action Install() In Visual Studio 2008, the uninstall action is not called, as follows: v1.0.1 custom action Install()
If you created custom actions relying on the old behavior, you need to modify your code for the new behavior. This behavior change affects only updates, not uninstalls.
CRUX:
So how to “Put the VS2008 behaviour back to how it worked in VS2005” (the old versions Uninstall custom action is called before the new version Install) .
Orca is the solution….
Steps:
- Open your compiled MSI using Orca.exe
- Select “InstallExecuteSequence” table from the left pane
- Change the #sequence number of “RemoveExistingProducts” to immediately after InstallInitialize.
Screen Shot with position of RemoveExistingProduct in VS2010 compiled project
Screen Shot after Re-positioning of RemoveExistingProduct using Orca.
Here you go…with the three step solution!!!
Happy Coding!!! 🙂