Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Install/bootstrap new runtimes during updates #9

Closed
caesay opened this issue Oct 21, 2021 · 6 comments
Closed

Install/bootstrap new runtimes during updates #9

caesay opened this issue Oct 21, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@caesay
Copy link
Member

caesay commented Oct 21, 2021

A user might ship a net5 app, and subsequently publish an update to net6 - but this is impossible with Squirrel as the runtime bootstrapping is done by Setup.exe which is not preserved.

Now that Update.exe is fully self-contained, we could move the runtime bootstrapping to Update.exe (or even Squirrel.dll) to allow new runtimes to be installed during updates.

We now have the capability to check the app manifest for the SquirrelAwareVersion attribute (and this should probably be the preferred way going forward as it works uniformly for native apps, C# apps, and single file apps).

Perhaps the runtime dependency could also be read from the manifest (net6), and we can check binaries during updates to confirm that all the required runtimes are indeed installed. This could also allow us to automatically update minor versions (eg. 5.0.6 to 5.0.7) if an app requests it.

@caesay caesay changed the title Update installed runtime Install/bootstrap new runtimes during updates Oct 21, 2021
@caesay caesay added the enhancement New feature or request label Dec 7, 2021
@simader
Copy link

simader commented Dec 20, 2021

Hi caesey,
I also expirenced, that on new installation the download of the .net6 runtime started automatically.
However on updates the following link is opened: https://dotnet.microsoft.com/en-us/download/dotnet/6.0/runtime

Is it possible to have the same logik on install and update?

@caesay
Copy link
Member Author

caesay commented Dec 20, 2021

Installing new versions of runtimes during updates was never a feature of the old Squirrel, but it's something I am considering adding in the next release which is why this issue is open as an enhancement.

@caesay
Copy link
Member Author

caesay commented Dec 20, 2021

Commit 791f34b and 160373e make it possible to install new runtimes while updating your app. It is not fully automatic.

If you were planning an update from .net5 to .net6, for example, you'd need to first push the below code on .net5. It would allow you to install net6 before your users get get the update.

I may revisit this later to see if it can be further automated, but I suspect not - because it requires the user to accept a UAC prompt while installing .net, and this should not be unexpected (eg. the user needs to be interacted with first)

private static async void UpdateMyApp()
{
    var net6 = Runtimes.DOTNET6_X64;
    var net6installed = await net6.CheckIsInstalled();
    // ask user if they would like to install net6 if it is not already installed
    if (!net6installed)
    {
        if (MessageBoxResult.Yes == MessageBox.Show("Would you like to install net6?", "Update", MessageBoxButton.YesNo))
        {
            // install net6 before we install our update
            var instPath = Path.GetTempFileName() + ".exe";
            await net6.DownloadToFile(instPath);
            await net6.InvokeInstaller(instPath, isQuiet: true);
        }
        else
        {
            // do not install your app update until net6 is installed
            return;
        }
    }

    // net6 is now installed, you can update normally
    using var mgr = new UpdateManager("https://the.place/you-host/updates");
    var newVersion = await mgr.UpdateApp();

    // optionally restart the app automatically, or ask the user if/when they want to restart
    if (newVersion != null)
    {
        UpdateManager.RestartApp();
    }
}

@caesay caesay closed this as completed Dec 20, 2021
@theresia-tobii
Copy link

theresia-tobii commented Jan 5, 2022

The problem with needing to add code to do this in the app itself is that users might miss that particular version if the app is not run very often. I would really like to see this being part of the update.exe and automated.

EDIT: This could potentially be solved by moving to a new update URL having the last version implement this workaround and start fetching updates from a new URL going forward.

@caesay
Copy link
Member Author

caesay commented Jan 5, 2022

Workaround suggested by @theresia-tobii for how to ensure that the necessary runtime is installed prior to updating to net5 or higher:

  • The old app fetches updates from "url1".
  • Add an update that uses net framework like before but clowd.squirrel with the workaround from Install/bootstrap new runtimes during updates #9.
  • Make this update fetch releases and updates from a new URL so that it will essentially be the last update from the old URL causing it to never be skipped in the update chain.
  • So now any new updates requiring the new framework will be fetched from the new URL and thus only be enabled from that last version that ensures the runtimes are installed.

@caesay
Copy link
Member Author

caesay commented May 2, 2022

After 02b5b60 users will be automatically prompted to install missing app dependencies when the app is started.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants