benjy
Posts: 35
Joined: Mon Nov 02, 2009 12:25 pm

Custom Action DLL: Unable to see AI_INSTALL etc.

Hi,

I am currently authoring a custom action DLL in C# that my AI installer will call. The logic in my custom action depends on whether the product is being installed, upgraded or removed. In order to try and detect this, I have tried to obtain the following properties from the Session object supplied to my DLL:
  • AI_INSTALL
  • AI_MAINT
  • OLDPRODUCTS
However, none of them are ever set. Please note that I can get the values of these properties:
  • SOURCEDIR
  • APPDIR
So what is wrong here? It is absolutely critical that I can detect this properly as my custom action needs to take different actions depending on what is happening.

FYI: The main issue I am facing is when upgrading... We have had to select the "unsintall first, then install" upgrade order as some of our components have changed. What I effectively need is for my custom action to not do anything during the uninstall phase, and then do it's work after the new installation has been made.

Please help!

Thanks,

Ben
benjy
Posts: 35
Joined: Mon Nov 02, 2009 12:25 pm

Re: Custom Action DLL: Unable to see AI_INSTALL etc.

Hi,

Well, I have made some progress. I was evidently wrong about the AI_MAINT and OLDPRODUCTS properties, as I can see that they do get values. Howevever, AI_MAINT only receives a value when you use the maintenance dialog; I know this sounds obvious but you don't get it when you use the Uninstall button in Programs and Features. Also, I have never been able to get a value in AI_INSTALL.

However, I still do have a problem. What I am trying to accomplish is that on upgrade, the details of an installed service are preserved. This worked fine when we used "install first, then uninstall" but not any more now that we have to use "uninstall first, then install". So I believe that I now have a strategy to deal with this but I am missing one important thing...

When the old version is "silently" uninstalled during the upgrade, is there anyway the old version knows that it is being upgraded, rather than being uninstalled? I have checked and it does not see the OLDPRODUCTS property, for example. Any suggestions?

Thanks,

Ben
benjy
Posts: 35
Joined: Mon Nov 02, 2009 12:25 pm

Re: Custom Action DLL: Unable to see AI_INSTALL etc.

Hi,

The answer is yes, there is... It's called UPGRADINGPRODUCTCODE:

http://msdn.microsoft.com/en-us/library/aa372380.aspx

As the documentation says, it is only configured when an old product is removed during an upgrade. Problem solved!

Regards,

Ben
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom Action DLL: Unable to see AI_INSTALL etc.

Hello Ben,

I'm glad you got this working. Also, please note that in order to configure a custom action not to be launched during an upgrade installation you can proceed like this:
- go to "Custom Actions" page and select your custom action
- in the custom action properties right pane under "Condition" section click on "Show upgrade options" hyperlink
- uncheck the "Replaced by a new version" option

If you have any questions just let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
benjy
Posts: 35
Joined: Mon Nov 02, 2009 12:25 pm

Re: Custom Action DLL: Unable to see AI_INSTALL etc.

Hi Daniel,

Thanks for the follow up... I hope that somebody else may find this thread useful!

Regards,

Ben
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom Action DLL: Unable to see AI_INSTALL etc.

You're welcome Ben. I'm sure this will be useful for future users in the same situation. Thank you for your contribution to Advanced Installer forums.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”