-
Notifications
You must be signed in to change notification settings - Fork 39
Install/bootstrap new runtimes during updates #9
Comments
Hi caesey, Is it possible to have the same logik on install and update? |
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. |
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();
}
} |
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. |
Workaround suggested by @theresia-tobii for how to ensure that the necessary runtime is installed prior to updating to net5 or higher:
|
After 02b5b60 users will be automatically prompted to install missing app dependencies when the app is started. |
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.
The text was updated successfully, but these errors were encountered: