Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Auto updater ? #336

Closed
giorgosavramopoulos opened this issue Nov 2, 2019 · 16 comments
Closed

How to use Auto updater ? #336

giorgosavramopoulos opened this issue Nov 2, 2019 · 16 comments
Labels

Comments

@giorgosavramopoulos
Copy link

I understand that this is not the place to ask questions, but i cannot understand how to configure Electron.NET to properly use the auto updater feature.
How to setup the remote repo where the update will be?
If you cannot answer here, please point to the right direction.. :)
Thanks!

@giorgosavramopoulos
Copy link
Author

OK, i figured it out so i though posting my answer in case someone else is interested..
So I wanted to see how to configure the updater for updating through a simple http server.
In electron.manifest.json i added this configuration inside build params:

"build": {
...,
"publish": {
"provider": "generic",
"url": "http://localhost:82",
"channel": "latest"
}
}

and i set up a local http server in iis on port 82 to serve files (need to include .yml in the mime types).
Inside the server path i put the files:

  • application.exe
  • application.exe.blockmap
  • latest.yml

Then when using eg. Electron.AutoUpdater.CheckForUpdatesAsync() it finds the files and tries to update.

@simonmurrell
Copy link

OK, i figured it out so i though posting my answer in case someone else is interested..
So I wanted to see how to configure the updater for updating through a simple http server.
In electron.manifest.json i added this configuration inside build params:

"build": {
...,
"publish": {
"provider": "generic",
"url": "http://localhost:82",
"channel": "latest"
}
}

and i set up a local http server in iis on port 82 to serve files (need to include .yml in the mime types).
Inside the server path i put the files:

  • application.exe
  • application.exe.blockmap
  • latest.yml

Then when using eg. Electron.AutoUpdater.CheckForUpdatesAsync() it finds the files and tries to update.

Hello

I tried this inside my build params of the electron.manifest.json file. It keeps looking at a local file in the obj\Host called dev_app_update.yml. It is not looking on the remote server I specified. I opened up Fiddler to see if it was making any http requests to the server. I am running the latest version of Electron.NET.

Regards,
Simon

@giorgosavramopoulos
Copy link
Author

Hi Simon,

Yes i forgor to mention that it does not work when running for debugging(electronize start..). You need to build for release (electronize build...)
Then under bin/Desktop will be the files you need to put in the http server and to see the updater working you either install the app and run it (i run it through cmd to see the logs) or run the exe under bin\Desktop\win-ia32-unpacked (this should work too i am not sure).
Under the folder bin\Desktop\win-ia32-unpacked\resources you should now see a app-update.yml file that should contain the info you have specified.

@simonmurrell
Copy link

Do you prompt the user to download it if an update is found or do you automatically download it? Does that method prompt the user

@giorgosavramopoulos
Copy link
Author

If you use it without any other AutoUpdater configuration it will download the update too and install it

@simonmurrell
Copy link

simonmurrell commented Nov 9, 2019

I see it is the base Electron.NET update information and not my application. Seems like this feature has not been implemented 100% yet...

@giorgosavramopoulos
Copy link
Author

where do you see that? i got it working the way i said above..

@simonmurrell
Copy link

I rebuilt it once again and now I see my info. Thanks. Let me see where this goes ;)

@simonmurrell
Copy link

Ok I see it is processing now. I added the YML file to the mime types. Do you then prompt the user to download or force it on them.

@giorgosavramopoulos
Copy link
Author

For that, it depends on what you want to do. I show a message that there is an update available and will be installed once the app quits and use QuitAndInstall method. You can see the available methods if you go inside AutoUpdater Class:
https://github.com/ElectronNET/Electron.NET/blob/master/ElectronNET.API/AutoUpdater.cs

@OmiCron07
Copy link

OK, i figured it out so i though posting my answer in case someone else is interested..
So I wanted to see how to configure the updater for updating through a simple http server.
In electron.manifest.json i added this configuration inside build params:

"build": {
...,
"publish": {
"provider": "generic",
"url": "http://localhost:82",
"channel": "latest"
}
}

and i set up a local http server in iis on port 82 to serve files (need to include .yml in the mime types).
Inside the server path i put the files:

* application.exe

* application.exe.blockmap

* latest.yml

Then when using eg. Electron.AutoUpdater.CheckForUpdatesAsync() it finds the files and tries to update.

Kudo for that! And it works with an Azure blob storage.

@GregorBiswanger
Copy link
Member

Please have a look at electron-builder. You can find the configuration for this under the new electron.manifest.json file at "build".

https://www.electron.build/auto-update

We have an sample in our API Demo App too:
https://github.com/ElectronNET/electron.net-api-demos

@sachinmakhre
Copy link

Please have a look at electron-builder. You can find the configuration for this under the new electron.manifest.json file at "build".

https://www.electron.build/auto-update

We have an sample in our API Demo App too:
https://github.com/ElectronNET/electron.net-api-demos

hi i am very new to electron and node ,unable to implement auto update please help...

@GregorBiswanger
Copy link
Member

@sachinmakhre Please refer to the instructions on the Internet for electron builder - Auto Update. This can be used 1:1 with Electron.NET.

@sachinmakhre
Copy link

@sachinmakhre Please refer to the instructions on the Internet for electron builder - Auto Update. This can be used 1:1 with Electron.NET.

thanks Gregor ! replying in very short time
still yet no luck , i am trying .NET 5 server blazer app with electron.net Api
no function is working ,require return undefine, where to write main process function ,
it will be great help if you a short demo on .NET 5 server blazer app this will help me understand where to write render and main process . i wish to bring your notice , we are not using MVC

@MSiffert
Copy link

MSiffert commented Oct 9, 2021

@sachinmakhre You could do something like this.

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (firstRender)
    {
        ElectronNET.API.Electron.AutoUpdater.OnUpdateNotAvailable += async e => await OnUpdateNotAvailable(e);
        ElectronNET.API.Electron.AutoUpdater.OnUpdateAvailable += async e => await OnUpdateAvailable(e);
        ElectronNET.API.Electron.AutoUpdater.OnError += async e => await OnInstallUpdateFailed(e);
    }
}

protected async Task CheckForUpdates()
{
    ElectronNET.API.Electron.AutoUpdater.AutoDownload = false;
    await ElectronNET.API.Electron.AutoUpdater.CheckForUpdatesAndNotifyAsync();
}

private async Task OnUpdateAvailable(UpdateInfo updateInfo)
{
    var message = $"PRODUCT {updateInfo.Version} is available.";
    var result = await ElectronService.ShowMessageBox(new MessageBoxOptions(message)
    {
        Title = "Updates",
        Type = MessageBoxType.info,
        NoLink = true,
        Buttons = new[]
        {
            "Update and restart application",
            "Update and install on app quit",
            "Cancel"
        }
    });
    
    if (result.Response == 0)
    {
        await ElectronNET.API.Electron.AutoUpdater.DownloadUpdateAsync();
        ElectronNET.API.Electron.AutoUpdater.QuitAndInstall();
    }
                        
    if (result.Response == 1)
    {
        ElectronNET.API.Electron.AutoUpdater.AutoInstallOnAppQuit = true;
        await ElectronNET.API.Electron.AutoUpdater.DownloadUpdateAsync();
    }
}

private async Task OnUpdateNotAvailable(UpdateInfo updateInfo)
{
    var message = "There is no update available.";
    await ElectronService.ShowMessageBox(new MessageBoxOptions(message)
    {
        Title = "Updates",
        Type = MessageBoxType.info,
        NoLink = true
    });
}

private async Task OnInstallUpdateFailed(string error)
{
    var message = $"Failed to install update. {error}";
    await ElectronService.ShowMessageBox(new MessageBoxOptions(message)
    {
        Title = "Updates",
        Type = MessageBoxType.info,
        NoLink = true
    });
}

This examples assumes that you have set up the update-server correctly as described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants