How to detect update using .NET 2 System.Configuration.Install?

I created a class derived from System.Configuration.Install for my installer.
But the code in Uninstall () is called when I try to update the application.
How can I detect that the user is trying to update instead of deleting?

Maybe this post explains it better than me:

My problem boils down to: when the user performs the update (i.e. double clicks on MyAppVer2.msi when they are already installed MyAppVer1.msi) the uninstall method inside my Installer is called first, but I have no visible property to check inside this method. to find that the update is running so that I can separate my code accordingly.

+4
source share
4 answers

Your installation project has a parameter that by default will โ€œdeleteโ€ previous versions, disable this flag, then you donโ€™t have to worry!

+1
source

A blind guess here, but I would start by checking the Installer.Context property for parameter . If this does not help, there might be something in the savedState parameter passed to Uninstall .

The last chance would be to request the user and install the child installers as appropriate.

0
source

The deployment project shipped with Visual Studio is NECESSARY to handle anything other than the simplest scenarios.

In your case, you need to do one of the following:

  • Determine how to set the flag before removing the original MSI, which you can check in the installer class.
  • Request the user visually in the installer class.
  • Redesign your install / uninstall logic so that it does not depend on the situation in which the uninstaller was called.
0
source

Is there a reason why you cannot use WIX, which can handle such things more efficiently, see the Upgrade tutorial. Here

0
source

Source: https://habr.com/ru/post/1277376/


All Articles