GeneralLibrary / GeneralUpdate

My ship looks old, who can help me upgrade it.
https://www.justerzhu.cn/
MIT License
304 stars 33 forks source link

主程序无法唤醒升级程序 #10

Closed JackGuogit closed 1 year ago

JackGuogit commented 1 year ago

这个方法public override bool StartApp(string appName, int appType)有逻辑bug,导致主程序无法唤醒升级程序。

switch (appType)
  {
      case AppType.ClientApp:
          Process.Start(path);
          Process.GetCurrentProcess().Kill();
          break;

      case AppType.UpgradeApp:
          Process.Start(path, Packet.ProcessBase64);
          break;
  }

修改为这样就可以了

JusterZhu commented 1 year ago

你调用的参数贴出来看看

JackGuogit commented 1 year ago

你调用的参数贴出来看看

        public GeneralClientBootstrap Config(string url, string appSecretKey, string appName = "GeneralUpdate.Upgrade")
        {
            if (string.IsNullOrEmpty(url)) throw new Exception("Url cannot be empty !");
            try
            {
                string basePath = System.Threading.Thread.GetDomain().BaseDirectory;
                Packet.InstallPath = basePath;
                Packet.AppSecretKey = appSecretKey;
                //update app.
                Packet.AppName = appName;
                string clienVersion = GetFileVersion(Path.Combine(basePath, $"{Packet.AppName}.exe"));
                Packet.ClientVersion = clienVersion;
                Packet.AppType = AppType.UpgradeApp;
                Packet.UpdateUrl = $"{url}/versions/{AppType.UpgradeApp}/{clienVersion}/{Packet.AppSecretKey}";
                //main app.
                string mainAppName = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName);
                string mainVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                Packet.MainUpdateUrl = $"{url}/versions/{AppType.ClientApp}/{mainVersion}/{Packet.AppSecretKey}";
                Packet.MainAppName = mainAppName;
                return this;
            }
            catch (Exception ex)
            {
                throw new GeneralUpdateException<ExceptionArgs>(ex.Message, ex.InnerException);
            }
        }

这是源代码的调用参数,用的是默认的Packet.AppType = AppType.UpgradeApp;这个参数传递到

                switch (appType)
                {
                    case AppType.ClientApp:
                        Process.Start(path, Packet.ProcessBase64);
                        Process.GetCurrentProcess().Kill();
                        break;

                    case AppType.UpgradeApp:
                        Process.Start(path);
                        break;
                }

是无法成功唤起升级程序的,使用默认参数的情况下,只有更改此处才能正确启动升级程序

JusterZhu commented 1 year ago

谢谢提交issue该问题已修复,可能是之前的PR修改错误了。