NetSparkleUpdater / NetSparkle

NetSparkle is a C#, cross-platform, highly-configurable software update framework with pre-built UI for .NET developers compatible with .NET 4.6.2/.NET 6+, WinForms, WPF, and Avalonia; uses Ed25519 signatures. View basic usage here in the README and try the samples for yourself.
https://netsparkleupdater.github.io/NetSparkle/
MIT License
609 stars 84 forks source link

Add a RelaunchAfterUpdate command prefix #255

Closed daniel-pastalab closed 2 years ago

daniel-pastalab commented 2 years ago

When set RelaunchAfterUpdate=true a line with the application is added to to the update .sh file to run after update. On linux (MANJARO, ZSH) a command or command prefix is needed to run the executable like:

dotnet app.dll or if packed into an linux app: ./app

So the idea is to be able to set a RelaunchAfterUpdatePrefix that will be added before the RelaunchAfterUpdate like dotnet or ./.

Here is a sample implementation:

/// <summary>
/// Defines a command prefix that will be used to open the executable (like "dotnet " or "./" on linux systems)
/// </summary>
public string RelaunchAfterUpdateCommandPrefix { get; set; }
if (RelaunchAfterUpdate)
{
     relaunchAfterUpdate = $@"
     cd ""{workingDir}""
     ""{RelaunchAfterUpdateCommandPrefix}{executableName}""";
}
Deadpikle commented 2 years ago

Hi @daniel-pastalab,

Thank you for your suggestion and your thorough comments on what would be needed

You can already change RestartExecutableName to do this, and it's as easy as updater.RestartExecutableName = "dotnet " + updater.RestartExecutableName; to do this in your own code. I'm not sure I want to add this parameter as proposed, but I'll leave this issue open for now. Thanks.

Deadpikle commented 2 years ago

@daniel-pastalab, Thanks for the suggestion. After looking at something myself, I realize that this was indeed a needed enhancement, so I have gone ahead and implemented it as you've suggested -- except without putting RelaunchAfterUpdateCommandPrefix inside quotes. ./ could in theory be set with the original RestartExecutableName, so the command prefix lets you do things outside of the quotes, e.g. run commands before the actual binary is started.

I added you as a co-author on the commit: https://github.com/NetSparkleUpdater/NetSparkle/commit/79d48dea8c9c9405bca74d1157cebd49c0a57ed5

Thanks! This is in NetSparkleUpdater 2.0.10.

danielospina-b commented 2 years ago

Hi @Deadpikle,

The implementation contains a space that I believe modifies the expected behaviour: https://github.com/NetSparkleUpdater/NetSparkle/blob/e2eacf9681ddd0c70e72bf6ee545b3cd3261e1f4/src/NetSparkle/SparkleUpdater.cs#L1352

Final script line ends up like: ./ "MyApp" this generates an error in bash: bash: ./: Is a directory. Where instead ./"MyApp" would work.

Deadpikle commented 2 years ago

@danielospina-b Thank you for bringing that to my attention. That would be a bug and a mishap on my part that is going to do not-very-happy-things to existing code. A fix will roll out within a few hours. Thank you again for bringing it to my attention.

Deadpikle commented 2 years ago

Fix is rolling out now. Removed the space and trimmed the overall line just in case. Thanks again.