Performing a minor upgrade

Any SharpSetup related discussions are welcome here including but not limited to questions about functionality, suggestions for improvements and technical questions.
Bendico
Posts: 17
Joined: Fri May 31, 2013 8:48 am

Performing a minor upgrade

Postby Bendico » Tue Nov 29, 2016 3:30 pm

I'm having trouble with the upgrade mechanism of SharpSetup. When performing an Upgrade, SharpSetup seems to always do an unistall of the installed package and then install the new one. The problem with this is that none of the important Msi properties specified in the original installation are retained. F.ex. INSTALLLOCATION. If the user has specified a different folder than the default in his original installation, then later perform an upgrade of the product, the new version seems to be installed in the default INSTALLLOCATION instead of the one previously specified. Am I correct, or have I maybe done something wrong in my coding?

If this is correct, it presents a significant problem to our users. They may have specified a different installation location for a good reason, and if the upgrade breaks that, it's not good. Is there a way to have SharpSetup 2.2 doing a minor upgrade instead, i.e. just "overwriting" the exisiting installation?

tomasz_grobelny
Posts: 463
Joined: Sat May 22, 2010 1:26 pm

Re: Performing a minor upgrade

Postby tomasz_grobelny » Tue Nov 29, 2016 8:07 pm

You can have a look at available upgrade methods here. Also you can read the desired properties when the old (installed) package is still open, "save" them in memory, open the new package and set the properties again and then start the installation.

Bendico
Posts: 17
Joined: Fri May 31, 2013 8:48 am

Re: Performing a minor upgrade

Postby Bendico » Wed Nov 30, 2016 12:28 pm

I think I understand it, but do you have a recommendation for how to implement the "saving" of properties in memory? I have tried in Gui, InstallationMode.cs,but when performing an upgrade, I can't seem to get the previous value of msi property INSTALLLOCATION, i.e. where the product is currently installed. Any clues of how to do this?

tomasz_grobelny
Posts: 463
Joined: Sat May 22, 2010 1:26 pm

Re: Performing a minor upgrade

Postby tomasz_grobelny » Wed Nov 30, 2016 10:54 pm

You could try calling MsiConnection.Instance.GetProperty("INSTALLLOCATION") in LifecycleAction method (ConnectionOpened section). Does it work for you?

Bendico
Posts: 17
Joined: Fri May 31, 2013 8:48 am

Re: Performing a minor upgrade

Postby Bendico » Thu Dec 01, 2016 10:14 am

No, it seems to return the default value of INSTALLOCATION. I think the problem lies in the upgrade mechanism, because I cannot see a way to intercept the overall upgrade process between the unstallation and the installation. As I understand it, this would be the right place to read the current installer property values and apply them to the installer that is about to begin. Am I making sense?

Bendico
Posts: 17
Joined: Fri May 31, 2013 8:48 am

Re: Performing a minor upgrade

Postby Bendico » Thu Dec 01, 2016 11:50 am

Solved it! Here is what I did:

1. Make sure you give your product an AppProductCode in Product.Defines.wxi.
2. In SetupWizard.cs, under

Code: Select all

case InstallationMode.Upgrade:
change

Code: Select all

AddStep(new InstallationStep(InstallationMode.Install));
to

Code: Select all

AddStep(new InstallationStep(InstallationMode.Upgrade));

3. In InstallationStep.cs under

Code: Select all

else if (mode == InstallationMode.Install){...}
add a new else if something like this:

Code: Select all

          else if (mode == InstallationMode.Upgrade)
                {
                    MsiConnection.Instance.Open(new Guid("{Your AppProductCode}"), false);
                       
                    string installLocation = MsiConnection.Instance.GetProperty("INSTALLLOCATION");

                    MsiConnection.Instance.Uninstall();

                    MsiConnection.Instance.Open(Resources.MainMsiFile, true);

                    MsiConnection.Instance.SetProperty("INSTALLLOCATION", installLocation);

                    PrerequisiteManager.Instance.Install();
                    MsiConnection.Instance.Install();
                }


So basically, I'm taking control over the Upgrade mode installation:
1. Open up the previously installed msi
2. Get the value of the INSTALLLOCATION property (and any other properties you want to migrate)
3. Uninstall this msi
4. Open up the new msi which we are about to install
5. Set the INSTALLLOCATION property for this msi to the stored value
6. Install the new msi


Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest