3

我正在尝试在我的 WPF 应用程序中实现自动更新功能。所以我正在测试一个临时项目并遵循本指南

这是我的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"}";
        }
    }
}

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

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

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

4

1 回答 1

2

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

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

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

于 2021-03-18T15:48:25.200 回答