Migrating from ClickOnce to AI - Advanced Installer Community
emoreau
Posts: 7
Joined: Fri Oct 12, 2018 5:05 pm

Migrating from ClickOnce to AI

Hi

We have an app that has is currently being updated to a large based (several thousands) of users through ClickOnce.

We are now evaluating Advanced Installer.

Is there a way to smoothly upgrade our users from ClickOnce to AI without asking them to uninstall the old app using ClickOnce and re-install the new one from Advanced Installer?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Migrating from ClickOnce to AI

Hi and welcome to our forums.

Thank you for your interest in Advanced Installer.

In order to link the new version of your product created with Advanced Installer with the old version created with ClickOnce, you only need to use the same Upgrade Code for them. You can set the Upgrade Code in the "Product Details" page, "Product IDs" tab from your Advanced Installer project.

Let me know if you need more details.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
emoreau
Posts: 7
Joined: Fri Oct 12, 2018 5:05 pm

Re: Migrating from ClickOnce to AI

Where do I get this Upgrade Code from?

I don't get how the already deployed application (using ClickOnce) will suddenly use the package generated by Advanced Installer? Do you have instructions about that?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Migrating from ClickOnce to AI

Hi,
Where do I get this Upgrade Code from?
The easiest way to get the Upgrade Code from your old packages, is to create a verbose log of their installation/uninstallation. Another way is to open them with the Microsoft Orca tool.
I don't get how the already deployed application (using ClickOnce) will suddenly use the package generated by Advanced Installer? Do you have instructions about that?
With Advanced Installer, when a version is released, an URL to an update file located on the vendor's server is also configured, so the updater will check that file to see if a new version is available.

I think ClickOnce proceeds in a similar way. When it checks for updates, it looks somewhere on your server to see if a newer version exists. So, you can place on the server, the new Advanced Installer package instead of the ClickOnce package that you used to place before.

Let me know if this helped, otherwise give me more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
emoreau
Posts: 7
Joined: Fri Oct 12, 2018 5:05 pm

Re: Migrating from ClickOnce to AI

So, you can place on the server, the new Advanced Installer package instead of the ClickOnce package that you used to place before.
I really doubt that copying the .msi generated by Advanced Installer in the folder where I used to put the ClickOnce deployment package will magically update the ClickOnce currently deployed to the newer Advanced Installer app without fully uninstalling and reinstalling.

We have several thousands of computers. We don't want to repeat that uninstall/reinstall process that many times! There must be a way!
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Migrating from ClickOnce to AI

Hi,

Sorry, I might have been wrong, indeed. I thought that your ClickOnce packages are also MSI-based.

In case, they are not MSI-based, you can implement a custom action in the Advanced Installer package, that will uninstall the ClickOnce package during its installation.

Then, the way I think it should work is like this: when your ClickOnce package checks for update, it finds and launch the Advanced Installer package. During the installation of this package, it will install the old ClickOnce package through the custom action you implemented.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
emoreau
Posts: 7
Joined: Fri Oct 12, 2018 5:05 pm

Re: Migrating from ClickOnce to AI

If I understand you correctly, ClickOnce will automatically get its future updates from a package generated by Advanced Installer even if they are 2 very different technologies? Have you ever tried it?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Migrating from ClickOnce to AI

No, I did not try this, but if its update process is as simple as the Advanced Installer one, it should work even if they are different technologies. Actually, all that ClickOnce needs to do, is to be able to download and launch the Advanced Installer package. After this, the Advanced Installer package can remove the ClickOnce product through a custom action and install itself as a new version of your product.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Collins
Posts: 142
Joined: Wed Oct 12, 2016 2:57 pm

Re: Migrating from ClickOnce to AI

I had a similar situation and what I ended up doing is uninstalling ClickOnce prior to installing the new version, since ClickOnce is installed under the 2.0 folder and the current application would be installed "Per Computer".

A custom action would run to remove ClickOnce entirely:

https://social.msdn.microsoft.com/Forum ... formssetup

Custom Action that I used:

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using System.Threading;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
using Microsoft.Deployment.WindowsInstaller;
using System.Security.Permissions;

namespace PRODUCTInstallerCustomActions.CustomActions
{
    public class UninstallClickOnceDesktopAction
        
    {

        [System.Runtime.InteropServices.DllImport("user32.dll")]

        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [System.Runtime.InteropServices.DllImport("user32.dll")]

        private static extern bool SetForegroundWindow(IntPtr hWnd);

        private Process process;
        private ProcessStartInfo startInfo;

        public void isAppRunning()
        {
            //
            //Run the below command in CMD to find the name of the process in the text file.
            //WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid
            //
            string processNameToKill = "PRODUCT Desktop"; //Change the name of the process to kill

            Process[] runningProcesses = Process.GetProcesses();

            foreach (Process myProcess in runningProcesses)
            {
                //Check if given process name is running
                if (myProcess.ProcessName == processNameToKill)
                {
                    killAppRunning(myProcess);
                }
            }
        }

        private void killAppRunning(Process myProcess)
        {
            //Ask the user if he wants to kill the process now or cancel the installation altogether
            DialogResult killMsgBox = MessageBox.Show("PRODUCT Desktop must not be running in order to get the new version\nIf you are ready to close the app, click OK.\nClick Cancel to abort the installation.", "PRODUCT Desktop Still Running", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            switch (killMsgBox)
            {
                case DialogResult.OK:
                    //Kill the process
                    myProcess.Kill();
                    findRegistryClickOnce();
                    break;
                case DialogResult.Cancel:
                    //Cancel whole instalation
                    break;
            }

        }

        private void findRegistryClickOnce()
        {
            string uninstallRegString = null; //Will be ClickOnce Uninstall String
            string valueToFind = "PRODUCT Desktop"; //Name of the application we want to uninstall (found in registry)
            string keyNameToFind = "DisplayName"; //Name of the Value in registry
            string uninstallValueName = "UninstallString"; //Name of the uninstall string
            string regProgsLocation = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //Registry location where we find all installed ClickOnce apps

            using (RegistryKey baseLocRegKey = Registry.CurrentUser.OpenSubKey(regProgsLocation))
            {
                //Console.WriteLine("There are {0} subkeys in here", baseLocRegKey.SubKeyCount.ToString());

                foreach (string subkeyfirstlevel in baseLocRegKey.GetSubKeyNames())
                {
                    // Console.WriteLine("{0,-8}: {1}", subkeyfirstlevel, baseLocRegKey.GetValueNames()); //can use to see what you find in registry

                    try
                    {
                        string subtest = baseLocRegKey.ToString() + "\\" + subkeyfirstlevel.ToString();

                        using (RegistryKey cropMeLocRegKey = Registry.CurrentUser.OpenSubKey(regProgsLocation + "\\" + subkeyfirstlevel))
                        {
                            //Console.WriteLine("Subkey DisplayName: " + cropMeLocRegKey.GetValueNames()); //can use to see what you find in registry
                            //For each 
                            foreach (string subkeysecondlevel in cropMeLocRegKey.GetValueNames())
                            {
                                //If the Value Name equals the name app to uninstall
                                if (cropMeLocRegKey.GetValue(keyNameToFind).ToString() == valueToFind)
                                {
                                    uninstallRegString = cropMeLocRegKey.GetValue(uninstallValueName).ToString();
                                    //Exit Foreach
                                    break;
                                }
                            }
                        }
                    }
                    catch (System.Security.SecurityException)
                    {
                        MessageBox.Show("security exception?");
                    }
                }
            }
            if (uninstallRegString != null)
            {
                batFileCreateStartProcess(uninstallRegString);
            }
        }

        private void batFileCreateStartProcess(string uninstallRegstring) //Creates batch file to run the uninstall from
        {
            string tempPathfile = Path.GetTempPath() + "ClickOnceDesktopuninstall.bat"; //Batch file name, which will be created in Window's temps foler

            if (!File.Exists(@tempPathfile))
            {
                using (FileStream createfile = File.Create(@tempPathfile))
                {
                    createfile.Close();
                }
            }

            using (StreamWriter writefile = new StreamWriter(@tempPathfile))
            {
                writefile.WriteLine(@"Start " + uninstallRegstring); //Writes our uninstall value found earlier in batch file
            }


            process = new Process();
            startInfo = new ProcessStartInfo();

            startInfo.FileName = tempPathfile;
            process.StartInfo = startInfo;
            process.Start();
            process.WaitForExit();

            File.Delete(tempPathfile); //Deletes the file

            removeClickOnceAuto();

        }

        private void removeClickOnceAuto() //Automation of clicks in the uninstall to remove the need of any user interactions
        {
            IntPtr myWindowHandle = IntPtr.Zero;

            for (int i = 0; i < 60 && myWindowHandle == IntPtr.Zero; i++)
            {

                Thread.Sleep(1500);

                myWindowHandle = FindWindow(null, "PRODUCT Desktop Maintenance");

            }

            if (myWindowHandle != IntPtr.Zero)
            {

                SetForegroundWindow(myWindowHandle);

                SendKeys.Send("+{TAB}"); // SHIFT-TAB

                SendKeys.Send("{ENTER}");

                SendKeys.Flush();
            }
        }


        internal Microsoft.Deployment.WindowsInstaller.ActionResult Execute()
        {
            throw new NotImplementedException();
        }
    }
}
After that custom action would run, then the new install would continue. I did it through an exe installer, but it may be possible to run this custom action first in an msi then continue the installation. Hope this helps.
emoreau
Posts: 7
Joined: Fri Oct 12, 2018 5:05 pm

Re: Migrating from ClickOnce to AI

Hi Collins

This is very interesting.

What have you done to upgrade your users from the ClickOnce deployed to the new Advanced Installer package?
Collins
Posts: 142
Joined: Wed Oct 12, 2016 2:57 pm

Re: Migrating from ClickOnce to AI

Emoreau,

There was no upgrade path for ClickOnce as the installation directory and shortcuts were completely different. The process was to completely remove the ClickOnce application with the custom action then install the new one using Advanced Installer.
emoreau
Posts: 7
Joined: Fri Oct 12, 2018 5:05 pm

Re: Migrating from ClickOnce to AI

this is exactly what I can't afford to do. We just have too many users
Collins
Posts: 142
Joined: Wed Oct 12, 2016 2:57 pm

Re: Migrating from ClickOnce to AI

You will eventually have to move away from that and it will only become harder later. Can't you stagger your conversion for a set amount of users and see how it goes and make changes if needed? If the upgrade works for them then you can increase your upgrade to more users.

Return to “Common Problems”