4

I'm attempting to use Squirrel.Windows with my application to install and auto update from it's GitHub repositories. Following along in the examples at

https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/getting-started/1-integrating.md

I was able to complete all steps successfully. I tested the install, application opens no problems. I updated and "releasified" it, and the local installed application updated as expected.

So with that, I know that Squirrel is working properly if I'm doing this from a local directory, however, I need to do this from GitHub. I was following the directions here

From that, I updated the code in my App.xaml.cs to the following

public partial class App : Application
{
    protected override async void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);
        MessageBox.Show(typeof(App).Assembly.GetName().Version.ToString());

        //  Check for application updates
        using (var mgr = UpdateManager.GitHubUpdateManager("https://github.com/Dartvalince/DiscerningEye"))
        {
            await mgr.Result.UpdateApp();
        }
    }

Next I go through the same process as before, creating the nupkg, and performing the releasify command with Squirrel. No issues here, good.

After all this, I perform a git commit and git push of the source up to GitHub. Everything on GitHub is updated with the latest commit. Good here

Next, on the GitHub page, I create a new release. The Tag used for the release is the same as the Assembly Version used in the .nupkg that was created. For the files to attach to the release, I drag and drop all the files from the Release folder that was created via Squirrel.

Ok, now everything is on GitHub. I then move into testing this to make sure when a user downloads all the files, then runs the Setup.exe, it installs properly and opens up. When i do this, I download each of the files into a folder on my desktop, then click the Setup.exe. When i do this, I get the expected MessageBox.Show(typeof(App).Assembly.GetName().Version.ToString()); MessageBox popup from the app, showing the correct Assembly version number, but then nothing. It's like at this point, it gets stuck in the Update part of the code and never goes past it. I can leave it sitting there overnight and nothing. I can even see the process running in memory in the Task Manager, so I know it hasn't errored out and closed, but it sits at 0% CPU usage and 0% Network usage.

Any help would be phenomenally appreciated.

Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
Chris Whitley
  • 181
  • 1
  • 5

1 Answers1

6

I figured this out, and wanted to post the answer for anyone else that may get to this point and have the same issue. It was all user error.

First, having the UpdateManager inside the App.xaml.cs's OnStartup method was causing the code execution to halt at the await until the update finished. I moved the update check to a method in the MainWindowViewModel.

From there, I wrapped the update code in a try/catch and used a MessageBox to show the exception messages. It was "Resource could not be found: Error 404".
I double checked the URL which I was using for the GitHubManager source, and it was the correct address to the repository page.
However, the issue was the / at the end of the URL. I changed it from

https://github.com/dartvalince/DiscerningEye/

to

https://github.com/dartvalince/DiscerningEye

and tested everything, and it's working now. This is the CheckForUpdate function within the MainWindowViewModel

private async void CheckForUpdate()
{
    try
    {
        using (var mgr = await UpdateManager.GitHubUpdateManager("https://github.com/dartvalince/DiscerningEye"))
        {
            updateManager = mgr;
            var release = await mgr.UpdateApp();
        }
    }
    catch (Exception ex)
    {
        string message = ex.Message + Environment.NewLine;
        if (ex.InnerException != null)
            message += ex.InnerException.Message;
        MessageBox.Show(message);
    }
}
Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
Chris Whitley
  • 181
  • 1
  • 5