-
Notifications
You must be signed in to change notification settings - Fork 85
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
WorkingDir incorrect in NetSparkleUpdater.RunDownloadedInstaller #187
Comments
👋🏻 Thanks for the reports!
This probably needs to be more obvious in the readme somewhere, and yes, if it's not set to true, the button should say 'Install' and not 'Install and Relaunch'. That'd be a bug.
Yeah this would be a bug and needs to be fixed; good catch.
Mmm....I agree with this, but probably need to add some docs that say "if your installer doesn't launch within 90 seconds, the app will restart without updating" or something. I think restarting an un-updated app would be preferable to doing nothing.
Makes sense.
Hmmmm... |
I spent a few hours going through the various options in the SO article. I tested without the new Uri wrapper and found small vestiges of the file:/// left behind (i.e. Path.GetDirectoryName(....Codebase)). Codebase definitely returns file:///C:/Program Files.../NetSparkle.dll In the end, the line I came up with worked for me (Winforms / .NetFramework. The only thing I didn't check was whether to use GetExecutingAssembly or GetEntryAssembly. In the end, I decided this really didn't matter. I couldn't think of a situation where they would be any different and in the end we are merely supplying a default value here for something which the NetSparkle user has full control of anyway. |
By the way, my moving of the relaunch lines after the :afterinstall label was purely aesthetic. NetSparkle has always relaunched after an unsuccessful install. So the moving of these lines does not change behaviour in any way as control flow will just ignore the label (as it always has anyway). We'd need a NoRelaunchAfterUnsuccessfulUpgrade or NoRelaunchAfterUnsuccessfulInstall property on the SparkleUpdater and then a minor bit of string building to slot in the "IF ERRORLEVEL 1" somewhere to implement this behaviour. Not worth the bother as I don't think anyone would ever want to use this. I agree with you when you say that restarting an un-updated app is preferable to doing nothing. |
Have made the following changes:
Still to do:
This will take a bit more work since we'd have to update the view models (Avalonia, WPF) with more things to be able to handle this properly. I didn't look at WinForms changes, but presumably that also needs adjustments. I think I never found this issue myself because the software I wrote that uses NetSparkle restarts the software via the installer, not via NetSparkle.
I hear you, but since it's configurable and likely different on .NET Framework vs .NET Core/5+, I need to see what the "best default" is. Perhaps for .NET Framework we can use what you've suggested (with a fallback to |
#187 -- more breaking changes in functionality, sorry, but things work as intended now!
This is now done.
This is now fixed and working on all 4 UIs. |
Many thanks! |
I had a look at Issue #183 to see if I might volunteer to help. In doing this I realised why my upgrades never restart the application after the upgrade. It's because I never set "RelaunchAfterUpdate = true" for my SparkleUpdater object. It defaults to false, so even though the caption in the button in UpdateAvailableWindow says "Install and Relaunch" my app never relaunched. Always meant to investigate this and now know why. Result. Might be worth putting this in the documentation. Maybe default value of RelaunchAfterUpdate should be true. Maybe button caption needs a visit...
However, in passing I had a look at the "cmd" file written into my Local/AppData/Temp folder and I noticed that it doesn't get the working directory correct.
Mine said something along the lines of:
So restarts have a "silent" error message and don't get the right working directory. This probably doesn't matter too much, as for most programs nowadays the working directory isn't that important.
The "file:///..." string has two problems
Reason being that Utilities.GetFullBaseDirectory() says:
// https://stackoverflow.com/a/837501/3938401
return System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
Reading the stackoverflow article and with a bit of testing, I came up with:
// https://stackoverflow.com/a/837501/3938401
return Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);
This works as I think it is intended. The new Uri(wrapper) is needed to handle the "file:///" thing and get a LocalPath and then the Path.GetDirectoryName returns the path that is wanted. This is discussed in a roundabout way in the stackoverflow article.
I then did this to NetSparkle.RunDownloadedInstaller
I did 3 things here.
So anyway, now I get:
Works a charm.
The text was updated successfully, but these errors were encountered: