Closed SkiTiSu closed 2 years ago
UPDATE: It seems that I closed the app while updating, but it cannot continue to cleanup the old app and nupkgs after next launch.
Old versions are cleaned up using the same logic as the old squirrel. Which is: old versions are deleted during every update if there are no processes running in that directory. Usually this means will be at least one version left over (so the current version, and the one previous version). eg:
This is a question that has been raised many times on the old Squirrel issues, eg. https://github.com/Squirrel/Squirrel.Windows/issues/1024 https://github.com/Squirrel/Squirrel.Windows/issues/1347 https://github.com/Squirrel/Squirrel.Windows/issues/1514
If you are not experiencing the behaviour I described above, please share the updater logs so I can see what the error is. If you are using the Update.exe command line, the log file should be available in your app directory. If you are using the C# SDK, you will need to register a logger yourself. You can do this using the SquirrelLocator.
If you are looking for a way to clean up the previous package on next launch yourself, there is no built-in way to achieve this. You can review how Squirrel itself does this, and I will consider adding a public helper function for this in a future version.
Hi, thank you for your reply.
I'm using C# SDK with UpdateManager.RestartAppWhenExited()
.
I've tested it will happen when I CLOSED the app while operating
[INFO] ApplyReleasesImpl: Writing files to app directory: C:\Users\WDAGUtilityAccount\AppData\Local\app\app-2.0.2
If app-2.0.2 is not fully extractd, the application can no longer be launched. If app-2.0.2 is extraced but not cleaned up the old version, it won't clean up them any more.
Here is the full log after DeltaPackageBuilder (waited them all set)
2022-04-06 13:00:38.513 [INFO] DeltaPackageBuilder: Updating metadata file: app.nuspec
2022-04-06 13:00:38.514 [INFO] DeltaPackageBuilder: Updating metadata file: splashimage.png
2022-04-06 13:00:38.514 [INFO] DeltaPackageBuilder: Updating metadata file: [Content_Types].xml
2022-04-06 13:00:38.514 [INFO] DeltaPackageBuilder: Updating metadata file: _rels\.rels
2022-04-06 13:00:38.514 [INFO] DeltaPackageBuilder: Updating metadata file: package\services\metadata\core-properties\e51c9547372c49e59e27c0d19aa327e9.psmdcp
2022-04-06 13:00:38.515 [INFO] DeltaPackageBuilder: Repacking into full package: C:\Users\WDAGUtilityAccount\AppData\Local\app\packages\app-2.0.2.nupkg
2022-04-06 13:01:19.888 [DEBU] Utility: Starting to delete: C:\Users\WDAGUtilityAccount\AppData\Local\SquirrelClowdTemp\tempf
2022-04-06 13:01:20.261 [DEBU] Utility: Starting to delete: C:\Users\WDAGUtilityAccount\AppData\Local\SquirrelClowdTemp\tempe
2022-04-06 13:01:21.987 [INFO] ApplyReleasesImpl: Writing files to app directory: C:\Users\WDAGUtilityAccount\AppData\Local\app\app-2.0.2
2022-04-06 13:01:22.100 [INFO] LogHost: Rigging execution stub for CefSharp.BrowserSubprocess_ExecutionStub.exe to C:\Users\WDAGUtilityAccount\AppData\Local\app\CefSharp.BrowserSubprocess.exe
2022-04-06 13:01:25.552 [INFO] LogHost: Rigging execution stub for app_ExecutionStub.exe to C:\Users\WDAGUtilityAccount\AppData\Local\app\app.exe
2022-04-06 13:01:28.703 [INFO] ApplyReleasesImpl: Squirrel Enabled Apps: [C:\Users\WDAGUtilityAccount\AppData\Local\app\app-2.0.2\app.exe]
2022-04-06 13:01:58.889 [ERRO] ApplyReleasesImpl: Couldn't run Squirrel hook, continuing: C:\Users\WDAGUtilityAccount\AppData\Local\app\app-2.0.2\app.exe: System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Squirrel.Utility.InvokeProcessUnsafeAsync(ProcessStartInfo psi, CancellationToken ct) in ./Internal/Utility.cs:line 288
at Squirrel.UpdateManager.ApplyReleasesImpl.<>c__DisplayClass10_0.<<invokePostInstall>b__0>d.MoveNext() in ./UpdateManager.ApplyReleases.cs:line 408
2022-04-06 13:01:58.889 [INFO] ApplyReleasesImpl: Starting fixPinnedExecutables
2022-04-06 13:01:58.893 [DEBU] ApplyReleasesImpl: Examining Pin: C:\Users\WDAGUtilityAccount\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\File Explorer.lnk
2022-04-06 13:01:58.897 [DEBU] ApplyReleasesImpl: Examining Pin: C:\Users\WDAGUtilityAccount\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Microsoft Edge.lnk
2022-04-06 13:01:58.916 [INFO] ApplyReleasesImpl: cleanDeadVersions: checking for version 2.0.2
2022-04-06 13:01:58.916 [INFO] ApplyReleasesImpl: cleanDeadVersions: exclude current version folder app-2.0.1
2022-04-06 13:01:58.916 [INFO] ApplyReleasesImpl: cleanDeadVersions: exclude new version folder app-2.0.2
2022-04-06 13:02:08.970 [ERRO] ApplyReleasesImpl: Coudln't run Squirrel hook, continuing: C:\Users\WDAGUtilityAccount\AppData\Local\app\app-2.0.0\app.exe: System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Squirrel.Utility.InvokeProcessUnsafeAsync(ProcessStartInfo psi, CancellationToken ct) in ./Internal/Utility.cs:line 288
at Squirrel.UpdateManager.ApplyReleasesImpl.<>c__DisplayClass14_1.<<cleanDeadVersions>b__7>d.MoveNext() in ./UpdateManager.ApplyReleases.cs:line 602
2022-04-06 13:02:08.984 [DEBU] Utility: Starting to delete: C:\Users\WDAGUtilityAccount\AppData\Local\app\app-2.0.0
2022-04-06 13:02:10.699 [INFO] InstallHelperImpl: Writing uninstaller registry entry
2022-04-06 13:02:10.730 [INFO] InstallHelperImpl: There was no icon found, will use 'C:\Users\WDAGUtilityAccount\AppData\Local\app\app-2.0.2\app.exe' for uninstall icon.
I also noticed that the app will show up once after extractd (and the log shows error). I think this happened because I add single instance feature (from https://stackoverflow.com/questions/14506406/wpf-single-instance-best-practices/23730146#23730146). It prevents the same app from launching twice.
I will test them more.
I saw there was a log message:
2022-04-06 13:02:08.984 [DEBU] Utility: Starting to delete: C:\Users\WDAGUtilityAccount\AppData\Local\app\app-2.0.0
Are you saying that it still failed to delete app-2.0.0 despite printing this message?
Regarding your single instance / mutex, and regarding the issues running Squirrel hooks in the logs, you need to take care to handle the Squirrel events (using SquirrelAwareApp.HandleEvents(...);
) before you create your mutex. The SquirrelAwareApp.HandleEvents
function needs to be the very first thing your application runs on start-up.
No, in this log it successfully deleted app-2.0.0.
I'll notice that, thanks a lot.
Okay, be sure to fix the HandleEvents (so it runs outside your mutex). I'm going to close this issue since you found that old versions are being deleted successfully. Feel free to open a new issue if you have any further questions.
Firstly, thank you for your excellent fork! I'm trying to use this but found all my old versions are still exists, where should I troubleshoot this problem?
By the way, my app is really big (400MB+), can I specify clean the previous version after success update instead of keep it?