Task StartRemoteProcess() { return(Task.Run(() => { var cmd = Runtime.ProcessService.CreateCommand(exePath); cmd.Arguments = ((IPEndPoint)listener.LocalEndpoint).Port + " " + DebugMode; if (!string.IsNullOrEmpty(workingDirectory)) { cmd.WorkingDirectory = workingDirectory; } if (environmentVariables != null) { foreach (var env in environmentVariables) { cmd.EnvironmentVariables [env.Key] = env.Value; } } // Explicitly propagate the PATH var to the process. It ensures that tools required // to run XS are also in the PATH for remote processes. cmd.EnvironmentVariables ["PATH"] = Environment.GetEnvironmentVariable("PATH"); cmd.ProcessExecutionArchitecture = ProcessExecutionArchitecture; process = executionHandler.Execute(cmd, console); process.Task.ContinueWith(t => ProcessExited(), mainCancelSource.Token); })); }
Task StartRemoteProcess() { return(Task.Run(() => { var cmd = Runtime.ProcessService.CreateCommand(exePath); cmd.Arguments = ((IPEndPoint)listener.LocalEndpoint).Port + " " + DebugMode; process = executionHandler.Execute(cmd, console); process.Task.ContinueWith(t => ProcessExited()); })); }
protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context) { CProjectConfiguration conf = (CProjectConfiguration)ActiveConfiguration; string command = conf.Output; string args = conf.CommandLineParameters; string dir = Path.GetFullPath(conf.OutputDirectory); string platform = "Native"; bool pause = conf.PauseConsoleOutput; IConsole console; if (conf.CompileTarget != CBinding.CompileTarget.Bin) { IdeApp.Services.MessageService.ShowMessage("Compile target is not an executable!"); return; } monitor.Log.WriteLine("Running project..."); if (conf.ExternalConsole) { console = context.ExternalConsoleFactory.CreateConsole(!pause); } else { console = context.ConsoleFactory.CreateConsole(!pause); } AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor(monitor); try { IExecutionHandler handler = context.ExecutionHandlerFactory.CreateExecutionHandler(platform); if (handler == null) { monitor.ReportError("Cannot execute \"" + command + "\". The selected execution mode is not supported in the " + platform + " platform.", null); return; } IProcessAsyncOperation op = handler.Execute(Path.Combine(dir, command), args, dir, console); operationMonitor.AddOperation(op); op.WaitForCompleted(); monitor.Log.WriteLine("The operation exited with code: {0}", op.ExitCode); } catch (Exception ex) { monitor.ReportError("Cannot execute \"" + command + "\"", ex); } finally { operationMonitor.Dispose(); console.Dispose(); } }
public void Start() { lock (this) { if (starting) { return; } starting = true; exitRequestEvent.Reset(); RemotingService.RegisterRemotingChannel(); BinaryFormatter bf = new BinaryFormatter(); ObjRef oref = RemotingServices.Marshal(this); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, oref); string sref = Convert.ToBase64String(ms.ToArray()); string tmpFile = null; if (executionHandlerFactory == null) { executionHandlerFactory = Runtime.SystemAssemblyService.CurrentRuntime.GetExecutionHandler(); } try { string location = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); location = Path.Combine(location, "mdhost.exe"); ProcessHostConsole cons = new ProcessHostConsole(); tmpFile = Path.GetTempFileName(); File.WriteAllText(tmpFile, sref + "\n" + Process.GetCurrentProcess().Id + "\n"); string arguments = string.Format("{0} \"{1}\"", id, tmpFile); DotNetExecutionCommand cmd = new DotNetExecutionCommand(location, arguments, AppDomain.CurrentDomain.BaseDirectory); cmd.DebugMode = isDebugMode; process = executionHandlerFactory.Execute(cmd, cons); Counters.ExternalHostProcesses++; process.Completed += ProcessExited; } catch (Exception ex) { if (tmpFile != null) { try { File.Delete(tmpFile); } catch { } } LoggingService.LogError(ex.ToString()); throw; } } }
Task StartRemoteProcess() { return(Task.Run(() => { var cmd = Runtime.ProcessService.CreateCommand(exePath); cmd.Arguments = ((IPEndPoint)listener.LocalEndpoint).Port + " " + DebugMode; // Explicitly propagate the PATH var to the process. It ensures that tools required // to run XS are also in the PATH for remote processes. cmd.EnvironmentVariables ["PATH"] = Environment.GetEnvironmentVariable("PATH"); process = executionHandler.Execute(cmd, console); process.Task.ContinueWith(t => ProcessExited()); })); }
public static IAsyncOperation ProfileProcess(IProfiler profiler, Process process) { if (IdeApp.ProjectOperations.CurrentRunOperation != null && !IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted) { return(IdeApp.ProjectOperations.CurrentRunOperation); } SwitchWorkbenchContext(ProfileWorkbenchContext); string workingDir = ProfilingService.GetProcessDirectory(process.Id); IExecutionHandler handler = profiler.GetProcessExecutionHandlerFactory(process); DotNetExecutionCommand cmd = new DotNetExecutionCommand(); cmd.WorkingDirectory = workingDir; return(handler.Execute(cmd, null /*context.ConsoleFactory.CreateConsole (true)*/)); }
public void Start(IList <string> userAssemblyPaths = null) { lock (this) { if (starting) { return; } starting = true; exitRequestEvent.Reset(); RemotingService.RegisterRemotingChannel(); BinaryFormatter bf = new BinaryFormatter(); ObjRef oref = RemotingServices.Marshal(this); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, oref); string sref = Convert.ToBase64String(ms.ToArray()); string tmpFile = null; if (executionHandlerFactory == null) { executionHandlerFactory = Runtime.SystemAssemblyService.CurrentRuntime.GetExecutionHandler(); } try { string location = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); location = Path.Combine(location, "mdhost.exe"); tmpFile = Path.GetTempFileName(); StreamWriter sw = new StreamWriter(tmpFile); sw.WriteLine(sref); sw.WriteLine(Process.GetCurrentProcess().Id); sw.WriteLine(Runtime.SystemAssemblyService.CurrentRuntime.RuntimeId); // Explicitly load Mono.Addins since the target runtime may not have it installed sw.WriteLine(2); sw.WriteLine(typeof(AddinManager).Assembly.Location); sw.WriteLine(typeof(Mono.Addins.Setup.SetupService).Assembly.Location); sw.Close(); string arguments = string.Format("{0} \"{1}\"", id, tmpFile); DotNetExecutionCommand cmd = new DotNetExecutionCommand(location, arguments, AppDomain.CurrentDomain.BaseDirectory); if (userAssemblyPaths != null) { cmd.UserAssemblyPaths = userAssemblyPaths; } cmd.DebugMode = isDebugMode; ProcessHostConsole cons = new ProcessHostConsole(); process = executionHandlerFactory.Execute(cmd, cons); Counters.ExternalHostProcesses++; process.Completed += ProcessExited; } catch (Exception ex) { if (tmpFile != null) { try { File.Delete(tmpFile); } catch { } } LoggingService.LogError(ex.ToString()); throw; } } }
public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console) { IExecutionHandler handler = Runtime.ProcessService.GetDefaultExecutionHandler(command); return(handler.Execute(command, console)); }