Squirrel.Windows
Squirrel.Windows copied to clipboard
Discussion - Expected Behavior Using MSI (First Run Hook)
I have a commercial product that is using Squirrel (very effectively, I might add) and there is one large client that has requested an MSI because they want to install the product using a terminal server environment.
I use quite a few of the first-run, app-update, etc. events to copy folders, set up my environment, blah blah blah. The app-install event IS triggering, The first-run event is NOT triggering.
I am testing it on my dev machine which DID have my app installed using the exe. I uninstalled all components and deleted the folder in LocalAppData as well. The app DOES install on reboot, but the first-run code is never executed.
Here is a segment from the log that shoes SOME failure in that regard. Not sure if this is related or not.
2021-08-24 17:35:43> ApplyReleasesImpl: Couldn't run Squirrel hook, continuing: C:\Users\veron\AppData\Local\MyAppName\app-8.1.12\MyAppName.exe: System.OperationCanceledException: The operation was canceled. at System.Threading.CancellationToken.ThrowOperationCanceledException() at Squirrel.Utility.<>c__DisplayClass11_0.<InvokeProcessAsync>b__0() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Squirrel.Utility.<InvokeProcessAsync>d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Squirrel.UpdateManager.ApplyReleasesImpl.<>c__DisplayClass10_0.<<invokePostInstall>b__0>d.MoveNext()
Any advice on the expected behavior when installing via MSI or how to "fix" the first run issue would be appreciated.
This error means the squirrel hook (eg. --squirrel-install
) timed out. Squirrel will execute your app with this argument and wait for 15 seconds. You need to handle command line argument, do any installation bits you need, and then exit your app before 15 seconds are up. Note that this is not a critical error, if your app has not exited it will simply carry on and try to re-run your app (almost right away) with the --squirrel-firstrun
argument. Is it possible your app is crashing on firstrun because the installation has not yet completed?
To answer the question posed above before I elaborate further: The app is not crashing on first-run. (I have it logging every step of the way, and it's not even making it to that point.) And wouldn't it crash on "regular" installation as well if that were the issue? It's been running successfully using the .exe install for over a year. Unfortunately, we have new users who are operating in a virtual server environment and their IT department wants to be able to install via group policy, which the .exe doesn't support. Hence the MSI issue. Now on to the elaboration.....
So I wanted to test a few things before I replied. The MSI installs without a hitch and the MSI Installer shows up in the program files. Upon restart, the app installs to the current user and the Squirrel-Initial-Install procedure runs successfully. (Installation does complete successfully.)
At which point, the app does NOT launch. (Unlike direct installation via the .exe where the initial-install hook runs and then the app opens, at which point the first-run hook is called.)
If I manually open the app, it launches, but then crashes (expected behavior) because the first-run hook was never called, and so the settings folder is never created. -- Again this is expected behavior, since the app requires that certain folders/files/etc. are created during the first run.
INTERESTING BEHAVIOR: If I install one version back and there is an update on the server, after the initial installation completes and I manually launch the app, the update installs. When I relaunch the app, the first-run hook IS activated.
WHY is the first run hook not being activated on the ACTUAL first run? Shouldn't it run without needing an update on the server?
Thanks in advance. :)
WHY is the first run hook not being activated on the ACTUAL first run? Shouldn't it run without needing an update on the server?
This is by-design, first-run doesn't execute in MSI installs because it'd be super jarring and Weird if a bunch of apps suddenly opened! MSIs are designed for Enterprise Deployment, and in Enterprise Deployment, when an admin installs stuff to your computer it's supposed to be silent
@anaisbetts THANK YOU!! That makes perfect sense.
So, then to dovetail off of your answer, two more questions:
-
Why would it then call the first-run hook after the first UPDATE is installed? Shouldn't it be silent the entire time and not trigger the "welcome form" on the first update? (which could be immediately or could be days/weeks/months away?)
-
What would best practice be for implementing the installation routines that would normally run in the first-run hook so that if there is not an update on the server, it will implement the code that is necessary for the app to actually run? (Welcome screen without the welcome screen, as it were?) I'd like to avoid having two different apps to maintain, if at all possible.
Just checking to see if there was an answer to the two questions above?
@veevandyke
- That sounds like a bug to be honest. In general though, you shouldn't do anything of note in
--squirrel-firstrun
, it's really meant to like, just give you a hint that you should show the Tutorial screen or something equivalent. Your actual install actions should be in--squirrel-install
and--squirrel-update
- I think I answered this in the first one? If not let me know.
- Yup! Got it. I'm copying some folders, and doing a secondary install that "requires" user consent, so I stuck that in the firstrun as part of the welcome screen. That's going to happen automatically with an external script for my MSI users, so that solves itself.
- Yes... you did. Thanks.
So now the question becomes.... how can I now PREVENT the firstrun from running when the app updates? Is there something I can manually trigger so squirrel doesn't think the update is the first time the app runs?
(Side note: if you give me a hint where to look, I can see if it's something I can try and fix in the code if you guys are still looking for help.)