首页 > 解决方案 > AutoUpdater.NET 不更新也不删除旧程序

问题描述

我在 WPF 程序中使用AutoUpdater和 Visual Studio 安装程序项目。更新我的项目时,它从未真正更新过。它只提供“修复”或“删除”我现有安装的选项。这会导致程序总是要求更新(因为它仍在旧版本 1.0.0.0 上)。

我的更新代码(MainWindow.xaml.cs):

AutoUpdater.Start(@"\\SERVER\foo\bar\update.xml", new NetworkCredential("user", "pass"));
AutoUpdater.ShowSkipButton = false;
AutoUpdater.Synchronous = true;
AutoUpdater.Mandatory = true;
AutoUpdater.UpdateMode = Mode.Forced;

我的更新.xml:

<?xml version="1.0" encoding="utf-8" ?>
<item>
  <version>1.0.1.2</version>
  <url>\\SERVER\foo\bar\setup.msi</url>
  <mandatory>true</mandatory>
</item>

我的部署项目设置:

DetectNewerInstalledVersion = False
RemovePreviousVersions = True
Version = 1.0.1.2

我的 AssemblyInfo.cs:

[assembly: AssemblyVersion("1.0.1.2")]
[assembly: AssemblyFileVersion("1.0.1.2")]

我更改设置版本(生成新的 ProductCode)以匹配 AssemblyVersion 和 AssemblyFileVersion。但是,当它进行更新时,它只提供修复或删除当前安装的选项。继续“修复”实际上不会更新程序。下次启动程序时,它仍然在旧版本上,并会要求再次更新。

UpgradeCode 保持不变。将 DetectNewerInstalledVersion 设置为 true 会导致 Windows 抛出错误“已安装旧版本”,但我试图使用户不必为每个更新卸载并重新安装。

在此处输入图像描述

我能做些什么来解决这个问题?

标签: c#visual-studiowindows-installerinstallationauto-update

解决方案


lblVersion.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();

        AutoUpdater.DownloadPath = System.IO.Path.GetTempPath() + "\\UpdateExtrator\\";
        //AutoUpdater.InstallationPath = Application.StartupPath;

        AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent;         
        AutoUpdater.ReportErrors = true;
        AutoUpdater.UpdateMode = Mode.Forced;
        AutoUpdater.RunUpdateAsAdmin = true;

推荐阅读