Skip to content
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

Restart with Avalonia #22

Closed
HendrikMennen opened this issue Aug 17, 2019 · 13 comments
Closed

Restart with Avalonia #22

HendrikMennen opened this issue Aug 17, 2019 · 13 comments
Labels
bug Something isn't working

Comments

@HendrikMennen
Copy link

HendrikMennen commented Aug 17, 2019

Automatic restarting does not work with Avalonia Applications.
It is probably because I don't have a .exe file.
In order to start it again it would need to do
dotnet MyApp.dll
It would be nice to have an option to support this.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Aug 17, 2019

Hi, are you using Onova 2.4.4?

@HendrikMennen
Copy link
Author

yes

@Tyrrrz
Copy link
Owner

Tyrrrz commented Aug 18, 2019

It should work in 2.4.4
Can you post your latest log file from %localappdata%/Onova/{Your app name}/Log.txt?

@HendrikMennen
Copy link
Author

HendrikMennen commented Aug 18, 2019

18-Aug-2019 02:54:11.764> Onova Updater v2.4.4.0 started with args: [C:\Users\HendrikMennen\source\repos\VHDP\VHDPlus\bin\Debug\netcoreapp2.1\VHDPlus.dll, C:\Users\HendrikMennen\AppData\Local\Onova\VHDPlus\0.3, True].
18-Aug-2019 02:54:11.770> Waiting for all running updatee instances to exit...
18-Aug-2019 02:54:11.977> Copying package contents from storage to updatee's directory...
18-Aug-2019 02:54:14.373> Restarting updatee...
18-Aug-2019 02:54:14.438> System.ComponentModel.Win32Exception (0x80004005): Der angegebenen Datei ist keine Anwendung zugeordnet
   bei System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   bei System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   bei Onova.Updater.Program.Update(String updateeFilePath, String packageContentDirPath, Boolean restartUpdatee)
   bei Onova.Updater.Program.Main(String[] args)

The path of the DLL is correct

Der angegebenen Datei ist keine Anwendung zugeordnet = There is no application associated with the specified file

@Tyrrrz Tyrrrz added the bug Something isn't working label Aug 18, 2019
@Tyrrrz
Copy link
Owner

Tyrrrz commented Aug 18, 2019

@Sewer56 have you checked, does it break for you as well?

@HendrikMennen
Copy link
Author

HendrikMennen commented Aug 18, 2019

If I try to do open the application with dotnet C:\Users\HendrikMennen\source\repos\VHDP\VHDPlus\bin\Debug\netcoreapp2.1\VHDPlus.dll it works fine
Was that your question?

@HendrikMennen
Copy link
Author

I guess it could be the same problem as this guy has:
dotnet/core#1857

@Tyrrrz
Copy link
Owner

Tyrrrz commented Aug 18, 2019

I was asking someone else who also had issues with .NET Core 3.0 app.
That issue doesn't seem related. I'll look into it next week.

@HendrikMennen
Copy link
Author

Line 45 - 73 in Updater - > Program.cs

var startInfo = new ProcessStartInfo
                {
                    WorkingDirectory = updateeDirPath
                };

                // If updatee is an .exe file - start it directly
                if (string.Equals(Path.GetExtension(updateeFilePath), ".exe", StringComparison.OrdinalIgnoreCase))
                {
                    startInfo.FileName = updateeFilePath;
                }
                // If not - figure out what to do with it
                else
                {
                    // If there's an .exe file with same name - start it instead
                    // Security vulnerability?
                    if (File.Exists(Path.ChangeExtension(updateeFilePath, ".exe")))
                    {
                        startInfo.FileName = Path.ChangeExtension(updateeFilePath, ".exe");
                    }
                    // Otherwise - start the updatee using dotnet SDK
                    else
                    {
                        startInfo.FileName = "dotnet";
                        startInfo.Arguments = updateeFilePath;
                    }
                }

                using (var restartedUpdateeProcess = Process.Start(updateeFilePath))
                    WriteLog($"Restarted as pid:{restartedUpdateeProcess?.Id}.");

You start the process there without using startInfo you created before.

Change

Process.Start(updateeFilePath)

to

Process.Start(startInfo)

And it works :)

@Sewer56
Copy link

Sewer56 commented Aug 18, 2019

Above is the correct solution.
I was about to check this myself, moving back from my fork temporarily but seems I was beat to it.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Aug 18, 2019

Excuse me while I knock myself out with a facepalm. That's what you get for not testing.

@Tyrrrz Tyrrrz closed this as completed in 271ad76 Aug 18, 2019
@HendrikMennen
Copy link
Author

Otherwise it works very well even on Linux. Just had to remove the "Onova works only on Windows warning", make it target .Net Standard 2.0
and change a little bit to make restarting work there too 💯 . Very nice and simple updater.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Aug 19, 2019

You can submit your changes as a pull request ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants