WindowsCliController.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Diagnostics;
  2. using System.IO;
  3. using System.Threading.Tasks;
  4. namespace SingularityGroup.HotReload.Editor.Cli {
  5. class WindowsCliController : ICliController {
  6. Process process;
  7. public string BinaryFileName => "CodePatcherCLI.exe";
  8. public string PlatformName => "win-x64";
  9. public bool CanOpenInBackground => true;
  10. public Task Start(StartArgs args) {
  11. process = Process.Start(new ProcessStartInfo {
  12. FileName = Path.GetFullPath(Path.Combine(args.executableTargetDir, "CodePatcherCLI.exe")),
  13. Arguments = args.cliArguments,
  14. UseShellExecute = !args.createNoWindow,
  15. CreateNoWindow = args.createNoWindow,
  16. });
  17. return Task.CompletedTask;
  18. }
  19. public async Task Stop() {
  20. await RequestHelper.KillServer();
  21. try {
  22. process?.CloseMainWindow();
  23. } catch {
  24. //ignored
  25. }
  26. process = null;
  27. }
  28. }
  29. }