Squirrel / Squirrel.Windows

An installation and update framework for Windows desktop apps
MIT License
7.35k stars 1.03k forks source link

Method not found: <Squirrel.UpdateInfo> Squirrel.UpdateManager.CheckForUpdate #1780

Closed BlagoCuljak closed 2 years ago

BlagoCuljak commented 2 years ago

Squirrel version(s) Updating from 1.9.1 to 2.0.1

Description We had some issues with updater in 1.9.1 version, it didn't want to restart the app anymore, reason unknown, and wanted to update to 2.0.1, but now we have this error now:

Method not found: 'System.Threading.Tasks.Task1 Squirrel.UpdateManager.CheckForUpdate(Boolean, System.Action1<Int32>)'.

static async Task<bool> UpdateApp()
        {
            using (var mgr = new UpdateManager("http://url.com/Releases/"))
            {
                //
                UpdateInfo updateInfo = await mgr.CheckForUpdate();
                if (updateInfo.ReleasesToApply.Any()) // Check if we have any update
                {
                    isUpdateInProgress = true;
                    string appdatapath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData); //moving config files to temp folder while updating
                    string pathtosettings = System.AppDomain.CurrentDomain.BaseDirectory + "\\appsettings.json";
                    string pathtoportals = System.AppDomain.CurrentDomain.BaseDirectory + "\\Portals.txt";
                    System.IO.File.Copy(pathtosettings, appdatapath + "\\appsettings.json", true);
                    System.IO.File.Copy(pathtoportals, appdatapath + "\\Portals.txt", true);
                    System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                    FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
                    string msg = App.Resources.Properties.Resources.Message_NewVersionUpdate;
                    try
                    {
                        msg += System.Environment.NewLine + System.Environment.NewLine + App.Resources.Properties.Resources.Message_CurrentVersion + ": " + updateInfo.CurrentlyInstalledVersion?.Version +
                        System.Environment.NewLine + App.Resources.Properties.Resources.Message_NewVersion + ": " + updateInfo.FutureReleaseEntry?.Version;
                    }
                    catch (Exception)
                    {
                        // skip through
                    }

                    MessageBox.Show(msg, "App One");

                    // Do the update

                    release = await mgr.UpdateApp();
                    if (release != null)
                    {
                        isUpdateInProgress = false;
                        try
                        {
                            System.Diagnostics.Process.Start("https://url.com/changelog/"); //Go to changelog URL
                        }
                        catch (Exception ex)
                        {
                            App.Logger.LoggingManager.LogErrorAsync("Error when trying to launch changelog -> ", ex);
                        }

                        UpdateManager.RestartApp();
                    }
                }

                // Restart the app if there was an update
            }

            return true;
        }
BlagoCuljak commented 2 years ago

Stupid me, I only updated main assebmly, not ViewModel assembly. Sorry, its not a bug.