在“找不到Update.exe,不是Squirrel安装的应用程序”错误中指定的Update.exe是什么?

问题描述

我正在尝试在WPF应用程序中实现自动更新功能。因此,我正在测试一个临时项目,并遵循this guide

这是我的MainWindow.xaml

<Window x:Class="AutoUpdate.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" Loaded="MainWindow_OnLoaded"
        Title="MainWindow" Height="350" Width="525">
    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" TextElement.FontSize="20">
        <TextBlock x:Name="CurrentVersion" Text="Loading..."/>
        <TextBlock x:Name="NewVersion" />
    </StackPanel>
</Window>

然后,我的xaml.cs文件

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private async void MainWindow_OnLoaded(object sender,RoutedEventArgs e)
    {
        using (var updateManager = new UpdateManager(@"C:\AutoUpdate\Releases"))
        {
            CurrentVersion.Text = $"Current version: {updateManager.CurrentlyInstalledVersion()}";
            var releaseEntry = await updateManager.UpdateApp();
            NewVersion.Text = $"Update Version: {releaseEntry?.Version.ToString() ?? "No update"}";
        }
    }
}

我所做的唯一不同是通过 NugetPackageExplorer 创建了.nupkg。但是运行时出现以下错误

找不到Update.exe,不是Squirrel安装的应用程序?

需要什么Update.exe?我在应用程序的localappdata中拥有它。可能缺少什么?

解决方法

您需要首先使用 squirrel.exe --releasify 发布您的应用,然后使用 Setup.exe 或 Setup.msi 安装该应用 - 它会起作用。

您无法调试 squirrel UpdateManager - 但有一种方法:您可以先在您的计算机上安装由 squirrel 发布的应用程序,然后将 Update.exe(来自 %LocalAppData%/YourAppName/)复制到您的二进制文件的父目录中项目。 (ProjectName/Bin/Debug 或 ProjectName/Bin/Release)。

更多信息:https://github.com/Squirrel/Squirrel.Windows