Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

How to upgrade when custom action on uninstall fails

I have a problem. We're evaluating Advanced Installer, and we have a scenario we want tested before we purchase it.
I just tried this scenario without success, so I created a post hoping there's a solution for this problem.
1. Say we created our program version 1.0.0 which is an MSI.
2. In the uninstall we have a custom action - which is a call to a .Net DLL. With some tweaking and the help of Gabriel, I made this custom action work. But say that we have some bug in our code, and calling this custom action raises an exception which causes the custom action to fail.
3. When the custom action in uninstall fails, you can't uninstall the program 1.0.0
4. So what we do is create an Upgrade 1.0.1, which has a FIX in the DLL that causes the exception when trying to uninstall.
5. And now I try to upgrade the program to 1.0.1, but it first tries to uninstall, and install the upgrade, and since the uninstall action fails, this causes the upgrade to fail.

I tried to create a new program with the option that it: "Install new version first and then uninstall old version" in the "Upgrades" tab (instead of the default: "Uninstall old version first and then install new version"). But this didn't help either...

How to solve this problem?
Dashut.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How to upgrade when custom action on uninstall fails

Hello,

This can easily be done by recaching the MSI as explained in this FAQ.
You will recache it with the new msi which has the fixed custom action. Note that the new MSI must have the same ProductCode and UpgradeCode as the installed one and the only difference between it and the already installed MSI should be the fixed custom action. No additional content like files, registries etc.

After recaching, you can continue with the update process as usual, by installing the new version of your product.

Let me know if this helped.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: How to upgrade when custom action on uninstall fails

I did exactly as you suggested (msiexec /fv mynewmsi.msi) and the only thing I saw was the trial dialog box popup, but then when I tried to uninstall: I still seem to trigger the "broken msi".
I tried also under the "Upgrades" section to use: "Install new version first and then uninstall old version" (instead of default: "Uninstall old version first and then install new version"), but that didn't help either.

When I did this check, the ONLY thing that I changed is the "bad DLL" and built the new MSI. I did NOT change the "Product Version" (in the "Product Details" section) or anything else.

What I'm trying to say is: I don't think that the cached MSI was changed. However, in order for uninstalling - and for my tests here only (meaning: not as a solution we're looking for) - I took the fixed DLL and place it in the installation folder: and then I could uninstall.

So at the beginning I was thinking that I should run an updated version, but as you suggested, I kept everything the SAME, but just fixed the DLL and created the MSI again. Then I ran the msiexec /fv mynewmsi.msi, and then I tried to go to windows: "Add or remove programs" and to uninstall. But that failed as I explained, but works only if I replace the BAD DLL in the installation folder with the GOOD one (so maybe this has nothing to do with cached MSI...?).

What am I doing wrong?
Am I supposed to use different options in the "upgrade" section then the default ones? (like: "Install new version first and then uninstall old version" instead of default: "Uninstall old version first and then install new version"?
maybe I should use: "Allow side by side installs of different product versions" instead of default: "Automatically upgrade older product versions"?
or this has nothing to do with this since I'm supposed to be replacing the SAME MSI (meaning: same product version) in the cache with a new/fixed one?

I hope this wasn't too long: I'm just trying to be as clear as possible.
Dashut.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to upgrade when custom action on uninstall fails

Hi Dashut,

If the problem is caused by an installed custom action, re-caching the MSI will not help. Instead, you can try creating a patch which updates the broken file. Our User Guide contains a Patch tutorial which may help you.

If you don't have an Enterprise license you can try this:
- create a new package which uses a search to find the installation folder of your product
- use a "Property set with formatted" custom action to set APPDIR to the search result
- remove "FolderDlg" from dialogs page
- make sure that the "Register product with Windows Installer" option is not checked in the "Product Details" page
- add the fixed file in "Application Folder" from Files and Folders page
- make sure it uses the "Ensure that this file overwrites any installed target file" option in the "Version" tab of the "Edit File" dialog
- build the project and install the package on a machine with a broken uninstall

This way the package will simply update the broken file so you can perform the uninstall.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: How to upgrade when custom action on uninstall fails

Since I'm using a 30 day trial version, I still have Enterprise license.
So I tried creating a patch as explained in the link you sent me.
Here are the steps I took in creating my msi and then the patch:
1. I created an Enterprise version 1.0.0 which actually only contains the TestDLL which is the one to run our Custom Action.
2. I created a Custom Action that will call the TestDLL when Uinstalled.
3. The TestDLL in the Custom Action will throw an Exception - as if there's some error (in the next version I fix this error and should succeed).
4. I built my Project and installed it. All went well.
5. Just for the test I tried to uninstall this version: but of course the Custom Action is called and the Uninstall fails (as expected).
6. I copy the 1.0.0 MSI to a temp directory: tmp1.
7. I change the Product Version to 1.0.1 and move to another tab. As you advised: when asked to Change the ProductCode I press the "NO".
8. I change the TestDLL with a "good" one (one that does NOT cause an Exception when the Custom Action is called).
9. I build this new project version (same Enterprise version that I started with but now version 1.0.1).
10. I copy the 1.0.1 MSI to another temp directory: tmp2 (now I'm ready to create the patch).
11. I now create a NEW Project - the Patch.
12. The Patch Wizard asks for the old and new MSI's, and since I have them in tmp1 and tmp2 I enter these MSI's.
13. I build the Patch (follow the Wizard to the end).
14. I now have a patch.msp file that I need to run. Remember: I also have the 1.0.0 MSI already installed and waiting to be upgraded by the patch.msp to 1.0.1 which has the NEW/FIXED TestDLL.
15. However, when I run the patch.msp I get a dialog which says the following: "The installed product does not match the installation source(s). Until a matching source...." and asks me to browse for "Use source".

This seems to me like some bug in the Patch. I did everything like I was supposed to. I even tried it again and again, but with the same result.
It feels for me like the Patch project is "broken"/not working as expected.

Your help will be greatly appreciated.
I'm using Advanced Installer evaluation 7.6.

Dashut.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to upgrade when custom action on uninstall fails

Hi Dashut,

I'm not sure why this happens. Can you please send us the patch .AIP (project) file you are using to support at advancedinstaller dot com so we can investigate it? Also, in the updated package did you increase the DLL version? This is required so the patch can detect the file change.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: How to upgrade when custom action on uninstall fails

Cosmin:
No: I did NOT increase the version in my TestDLL. I'll check this again after I increase the version for the DLL.
However, I upgraded to Advanced Installer 7.6.1, and I just can't make the Custom Action work! I don't add any new property, I just leave it as it is, but the Custom Action is either NOT called, or creates an error when trying to call it.
Something in the Custom Action is broken in Advanced Installer 7.6.1. I also saw this comment from another user in the board/forum.
So my post: ".Net Custom Action not working when trying to add property"
http://www.advancedinstaller.com/forums ... =2&t=10918
is still unsolved. At the time, I played and played until it suddenly started working: but this is not a solution...
When will this be fixed?
Dashut.

P.S: I tried creating an Enterprise project (1.0.0) that only has TestDLL but does NOT call the Custom Action, and then I created a fixed TestDLL without calling the Custom Action (1.0.1), and then created a Patch: that worked. It seemed to have inserted the new TestDLL after the Patch. However, I did not increase the version for the TestDLL... Doing the same with calling the Custom Action did not work: as I explained. I will try now with increasing the TestDLL version: but I also have to "battle" with Advanced Installer to call the Custom Action (which I think there's a bug there).
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to upgrade when custom action on uninstall fails

Hi,
However, I upgraded to Advanced Installer 7.6.1, and I just can't make the Custom Action work!
Does the custom action need Administrator privileges? If so, it should run as Deferred with no impersonation. We tested your project with the DLL you sent and the custom action is executed correctly. How are you determining if the custom action is called or not?
So my post: ".Net Custom Action not working when trying to add property"
viewtopic.php?f=2&t=10918
is still unsolved. At the time, I played and played until it suddenly started working: but this is not a solution...
When will this be fixed?
Unfortunately we cannot reproduce this behavior.
Doing the same with calling the Custom Action did not work: as I explained.
Are you trying to run the custom action during the patch installation? If so, it needs to have the condition "PATCH". The user guide contains the Create patch custom action how-to which may help you.

If this happens during a MSI installation, can you please send us a verbose log of the install process so we can investigate it?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: How to upgrade when custom action on uninstall fails

I can try another operatiing system. I'm currently using Windows XP without any problems (Administrative rights).
As I have mentioned: I have managed to run the Custom Action after "playing" with it.
By saying "Playing" I mean: create Custom action, then removing it, then creating it again, then moving (drag and drop) it from "install" to "uninstall" and so on.
Because I have managed to make it work before, I don't believe it's Administrative rights that I'm missing here.
We have Windows7 and Server 2003 and Server 2008 here in the office. I can try on those too (ah.. and also Vista).

I can also try to completely uninstall Advanced Installer and reinstall it...
Dashut.
Dashut
Posts: 142
Joined: Tue May 04, 2010 4:41 pm

Re: How to upgrade when custom action on uninstall fails

Everything works now! explain in thread:
http://www.advancedinstaller.com/forums ... 149#p30149
Basically, uninstalled Advaned Installer (completely!) killed "dangling" msiexec.exe processes, installed Advanced Installer 7.6.1 and Custom Action + Patching works!

Again, thanks for all.
Dashut.

Return to “Common Problems”