-
Notifications
You must be signed in to change notification settings - Fork 245
Description
程序在启动的时候,检测是否更新,有更新会强制更新,程序启动后有一个手动检测更新,
有更新会使用命令行的形式调用.exe进行更新。
由于两段逻辑是一样,于是将检测的逻辑单独封装成如下代码
但是 .net core的项目发布成单文件的项目,程序启动会报单文件那个错误,而手动检测不会。
是否可以将源码中那个单文件的异常直接关闭?
var updater = FSLib.App.SimpleUpdater.Updater.CreateUpdaterInstance(Config.UpdaterURI);
updater.DownloadUpdateInfoFinished += (e, a) =>
{
updater.Context.EnableEmbedDialog = false;
updater.Context.ForceUpdate = false;
updater.Context.MustUpdate = false;
updater.Context.UpdateInfo.ForceUpdate = false;
updater.Context.UpdateInfo.MustUpdate = false;
};
updater.UpdateError += (e, a) => { };
updater.UpdatesAvailable += (e, a) =>
{
var message = "将升级 {0} (版本 {1}) 到 版本 {2},请等待升级完成。";
var buttons = MessageBoxButtons.OKCancel;
if (!ManualCheckUpdate)
{
message = "将升级 {0} (版本 {1}) 到 版本 {2},请等待升级完成。\r\n\r\n如果无法升级,软件将无法使用。";
buttons = MessageBoxButtons.OK;
}
var dialog = MessageBox.Show(
string.Format(
message,
updater.Context.UpdateInfo.AppName,
updater.Context.CurrentVersion,
updater.Context.UpdateInfo.AppVersion),
"信息",
buttons,
MessageBoxIcon.Information);
if (dialog == DialogResult.OK)
{
StartExternalUpdater();
}
};