question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Restart with Avalonia

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
HendrikMennencommented, Aug 19, 2019

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.

1reaction
HendrikMennencommented, Aug 18, 2019

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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Application Lifetimes
Allows you to subscribe to Startup Exit events and explicitly shutdown the application by calling Shutdown method. Also provides the control of the ......
Read more >
Getting Started with Avalonia
Your Avalonia application is now up and running. You can open the MyApp folder to start improving and building upon your application. Edit...
Read more >
How can we change the default shutdown mode of an ...
1 Answer 1 ... You can set it in Main() via StartWithClassicDesktopLifetime(T, string[], ShutdownMode) method. EG: In the "Avalonia Application" ...
Read more >
.NET source generation suddenly shows red code, fixed via ...
AttachDevTools(); to an Avalonia Window and it started acting up. ... almost unusable at times having to restart the IDE every 5-15 minutes....
Read more >
Unable to launch a process. - Raspberry Pi Forums
I am new to Linux and systemd so I'm not sure if the following script is permitted. I want to launch "myRUNNINGAPP" from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found