Squirrel / Squirrel.Windows

An installation and update framework for Windows desktop apps
MIT License
7.32k stars 1.03k forks source link

Several things i do not know how to achieve with Squirrel #639

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi,

i like squirrel, did take a while until i managed to get it running in a basic way but it does. But what i did not figured out is:

Thanks for every help Daniel

PS: i am using VS2015 and C#

dealproc commented 8 years ago

do you possibly have an ability to post your sample project up so that others can take a look and better advise on what you may have done incorrectly?

ghost commented 8 years ago

okay, some snippets i did not integrate it in program.cs, because then it opened the app before the update

using Squirrel;

namespace VMFClient
{

    public partial class VMFClient : MetroForm
    {
        UpdateManager updates = new UpdateManager("http://www.example.com/downloads");
        ...
    } 
...
private void Form1_Load(object sender, EventArgs e)
   {
       updates.CheckForUpdate();
       ...
    }
private void Form1_FormClosing(object sender, EventArgs e)
   {
       updates.Dispose();
    }
public class UpdateManager : IDisposable
    {
        private readonly IUpdateManager _updateManager;

        public UpdateManager(string updateURL)
        {
            _updateManager = new Squirrel.UpdateManager(updateURL);
        }

        public event EventHandler VersionUpdatePending;
        public event EventHandler VersionUpdated;

        public void CheckForUpdate()
        {
            InvokeUpdate();
        }

        public void Dispose()
        {
            _updateManager.Dispose();
        }

        protected virtual void OnVersionUpdated()
        {
            if (VersionUpdated != null) VersionUpdated(this, EventArgs.Empty);
        }

        protected virtual void OnVersionUpdatesPending()
        {
            if (VersionUpdatePending != null) VersionUpdatePending(this, EventArgs.Empty);
        }

        private async void InvokeUpdate()
        {
            var updateInfo = await _updateManager.CheckForUpdate();
            if (updateInfo.ReleasesToApply.Any())
            {
                OnVersionUpdatesPending();
            }
            var releaseEntry = await _updateManager.UpdateApp();
            if (releaseEntry != null)
            {
                OnVersionUpdated();
            }
        }
    }

this are all lines that are reffering to squirrel

oh and i forget, how do i say squirrel to delete the old version after update?

dealproc commented 8 years ago

how do i say that it shall generate and update shortcuts?

so by default, making your app Squirrel Aware will make a shortcut for its *.exe

how do i say that it shall close on update and then reopen, because now the updater throws an exception when the old version opens the new one?

I'm looking at your UpdateManager class, and you have private async void InvokeUpdate() and public void CheckForUpdate(), but those are all encapsulating tasks. It seems from what I can flow, you may possibly be in the midst of an update, and be trying to restart the new version before the update has completed successfully. You may want to update this to be all task driven.

how do i make start menu entries?

I think this is one that I need to defer to others to assist with. I will be looking into this as well in the coming days. If I have an answer for you here, I will surely post it for you.

HTH

Thieum commented 5 years ago

@d0narnbl1tz did the previous comment answered all your questions? If so, you can close this issue.