private static ExecutionCommand CreateExecutionCommand(NMEProject project, NMEProjectConfiguration configuration) { string exe = "haxelib"; string args = "run nme run \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower(); if (configuration.DebugMode) { args += " -debug"; } if (project.AdditionalArguments != "") { args += " " + project.AdditionalArguments; } if (configuration.AdditionalArguments != "") { args += " " + configuration.AdditionalArguments; } NativeExecutionCommand cmd = new NativeExecutionCommand(exe); cmd.Arguments = args; cmd.WorkingDirectory = project.BaseDirectory.FullPath; return(cmd); }
public DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command) { NativeExecutionCommand pec = (NativeExecutionCommand)command; HxcppDebuggerStartInfo startInfo = new HxcppDebuggerStartInfo(); if (command is OpenFLExecutionCommand) { startInfo.Pathes = ((OpenFLExecutionCommand)command).Pathes; } else { startInfo.Pathes = new string[0]; } startInfo.Command = pec.Command; startInfo.Arguments = pec.Arguments; startInfo.WorkingDirectory = pec.WorkingDirectory; if (pec.EnvironmentVariables.Count > 0) { foreach (KeyValuePair <string, string> val in pec.EnvironmentVariables) { startInfo.EnvironmentVariables [val.Key] = val.Value; } } return(startInfo); }
protected override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) { return(Task.Factory.StartNew(async() => { ExternalConsole console = context.ExternalConsoleFactory.CreateConsole(false, monitor.CancellationToken); string targetName = ""; foreach (var target in fileFormat.Targets.Values) { if (target.Type == CMakeTarget.Types.Binary) { targetName = target.Name; break; } } if (string.IsNullOrEmpty(targetName)) { monitor.ReportError("Can't find an executable target."); return; } FilePath f = BaseDirectory.Combine(outputDirectory); NativeExecutionCommand cmd; if (File.Exists(f.Combine(targetName))) { cmd = new NativeExecutionCommand(f.Combine(targetName)); } else if (File.Exists(f.Combine(string.Format("{0}.{1}", targetName, "exe")))) { cmd = new NativeExecutionCommand(f.Combine(string.Format("{0}.{1}", targetName, "exe"))); } else if (File.Exists(f.Combine("./Debug", targetName))) { cmd = new NativeExecutionCommand(f.Combine("./Debug", targetName)); } else if (File.Exists(f.Combine("./Debug", string.Format("{0}.{1}", targetName, "exe")))) { cmd = new NativeExecutionCommand(f.Combine("./Debug", string.Format("{0}.{1}", targetName, "exe"))); } else { monitor.ReportError("Can't determine executable path."); return; } try { var handler = Runtime.ProcessService.GetDefaultExecutionHandler(cmd); var op = handler.Execute(cmd, console); using (var t = monitor.CancellationToken.Register(op.Cancel)) await op.Task; monitor.Log.WriteLine("The operation exited with code: {0}", op.ExitCode); } catch (Exception ex) { monitor.ReportError("Can't execute the target.", ex); } finally { console.Dispose(); } })); }
int StartCustomTestHost(TestProcessStartInfo startInfo, TestContext currentTestContext) { OperationConsole console = currentTestContext.ExecutionContext.ConsoleFactory.CreateConsole( OperationConsoleFactory.CreateConsoleOptions.Default.WithTitle(GettextCatalog.GetString("Unit Tests"))); ExecutionCommand command; if (runJobInProgress.Project is DotNetProject dnp) { if (dnp.HasFlavor <DotNetCoreProjectExtension> () && dnp.TargetFramework.IsNetCoreApp()) { command = new DotNetCoreExecutionCommand( startInfo.WorkingDirectory, startInfo.FileName, startInfo.Arguments ) { EnvironmentVariables = startInfo.EnvironmentVariables }; ((DotNetCoreExecutionCommand)command).Command = startInfo.FileName; ((DotNetCoreExecutionCommand)command).Arguments = startInfo.Arguments; } else { var portArgument = startInfo.Arguments.IndexOf(" --port", StringComparison.Ordinal); var assembly = startInfo.Arguments.Remove(portArgument - 1).Trim(new char[] { '"' }); var arguments = startInfo.Arguments.Substring(portArgument + 1); command = new DotNetExecutionCommand( assembly, arguments, startInfo.WorkingDirectory, startInfo.EnvironmentVariables ); } } else { command = new NativeExecutionCommand( startInfo.WorkingDirectory, startInfo.FileName, startInfo.Arguments, startInfo.EnvironmentVariables); } runJobInProgress.ProcessOperation = currentTestContext.ExecutionContext.ExecutionHandler.Execute(command, console); var eventProcessSet = new ManualResetEvent(false); runJobInProgress.ProcessOperation.ProcessIdSet += delegate { eventProcessSet.Set(); }; if (runJobInProgress.ProcessOperation.ProcessId == 0) { if (!eventProcessSet.WaitOne(5000) && runJobInProgress.ProcessOperation.ProcessId == 0) { throw new Exception("Timeout, process id not set."); } } return(runJobInProgress.ProcessOperation.ProcessId); }
ExecutionCommand CreateExecutionCommand(ValaProjectConfiguration conf) { NativeExecutionCommand cmd = new NativeExecutionCommand(); cmd.Command = Path.Combine(conf.OutputDirectory, conf.Output); cmd.Arguments = conf.CommandLineParameters; cmd.WorkingDirectory = Path.GetFullPath(conf.OutputDirectory); return(cmd); }
public override ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console) { // run without debugger var cmd = (RhinoExecutionCommand)command; var nativeCmd = new NativeExecutionCommand(cmd.ExecutablePath, cmd.Arguments, cmd.WorkingDirectory, cmd.EnvironmentVariables); return(base.Execute(nativeCmd, console)); }
protected virtual ExecutionCommand CreateExecutionCommand(DProjectConfiguration conf) { var app = GetOutputFileName(conf.Selector); var cmd = new NativeExecutionCommand(app); cmd.Arguments = conf.CommandLineParameters; cmd.WorkingDirectory = conf.OutputDirectory.ToAbsolute(BaseDirectory); cmd.EnvironmentVariables = conf.EnvironmentVariables; return(cmd); }
protected virtual ExecutionCommand CreateExecutionCommand(CProjectConfiguration conf) { string app = Path.Combine(conf.OutputDirectory, conf.Output); NativeExecutionCommand cmd = new NativeExecutionCommand(app); cmd.Arguments = conf.CommandLineParameters; cmd.WorkingDirectory = Path.GetFullPath(conf.OutputDirectory); cmd.EnvironmentVariables = conf.EnvironmentVariables; return(cmd); }
public override IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console) { PythonExecutionCommand cmd = (PythonExecutionCommand)command; string[] args = cmd.Configuration.Runtime.GetArguments(cmd.Configuration); string dir = Path.GetFullPath(cmd.Configuration.OutputDirectory); NativeExecutionCommand ncmd = new NativeExecutionCommand(cmd.Configuration.Runtime.Path, string.Join(" ", args), dir, cmd.Configuration.EnvironmentVariables); return(base.Execute(ncmd, console)); }
public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console) { var cmd = (AspNetExecutionCommand)command; var xspPath = GetXspPath(cmd); var evars = new Dictionary <string, string>(cmd.EnvironmentVariables); foreach (var v in cmd.TargetRuntime.GetToolsExecutionEnvironment(cmd.TargetFramework).Variables) { if (!evars.ContainsKey(v.Key)) { evars.Add(v.Key, v.Value); } } //HACK: work around Mono trying to create registry in non-writable location if (cmd.TargetRuntime is MonoTargetRuntime && !Platform.IsWindows) { evars ["MONO_REGISTRY_PATH"] = UserProfile.Current.TempDir.Combine("aspnet-registry"); } //if it's a script, use a native execution handler if (xspPath.Extension != ".exe") { //set mono debug mode if project's in debug mode if (cmd.DebugMode) { evars ["MONO_OPTIONS"] = "--debug"; } var ncmd = new NativeExecutionCommand( xspPath, cmd.XspParameters.GetXspParameters() + " --nonstop", cmd.BaseDirectory, evars); return(Runtime.ProcessService.GetDefaultExecutionHandler(ncmd).Execute(ncmd, console)); } // Set DEVPATH when running on Windows (notice that this has no effect unless // <developmentMode developerInstallation="true" /> is set in xsp2.exe.config if (cmd.TargetRuntime is MsNetTargetRuntime) { evars["DEVPATH"] = Path.GetDirectoryName(xspPath); } var netCmd = new DotNetExecutionCommand( xspPath, cmd.XspParameters.GetXspParameters() + " --nonstop", cmd.BaseDirectory, evars); netCmd.DebugMode = cmd.DebugMode; return(cmd.TargetRuntime.GetExecutionHandler().Execute(netCmd, console)); }
public bool CanDebugCommand(ExecutionCommand command) { NativeExecutionCommand cmd = command as NativeExecutionCommand; if (cmd == null) { return(false); } string file = FindFile(cmd.Command); if (!File.Exists(file)) { // The provided file is not guaranteed to exist. If it doesn't // we assume we can execute it because otherwise the run command // in the IDE will be disabled, and that's not good because that // command will build the project if the exec doesn't yet exist. return(true); } file = Path.GetFullPath(file); DateTime currentTime = File.GetLastWriteTime(file); FileData data; if (fileCheckCache.TryGetValue(file, out data)) { if (data.LastCheck == currentTime) { return(data.IsExe); } } data.LastCheck = currentTime; try { data.IsExe = IsExecutable(file); } catch (IOException ex) { // The file could still be in use by compiler, so don't want to report that the file is not an exe return(false); } catch { data.IsExe = false; } fileCheckCache[file] = data; return(data.IsExe); }
public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console) { var cmd = (AspNetExecutionCommand)command; var xspName = GetXspName(cmd); var xspPath = GetXspPath(cmd, xspName); if (xspPath.IsNullOrEmpty || !File.Exists(xspPath)) { throw new UserException(string.Format("The \"{0}\" web server cannot be started. Please ensure that it is installed.", xspName), null); } //if it's a script, use a native execution handler if (xspPath.Extension != ".exe") { //set mono debug mode if project's in debug mode var envVars = cmd.TargetRuntime.GetToolsExecutionEnvironment(cmd.TargetFramework).Variables; if (cmd.DebugMode) { envVars = new Dictionary <string, string> (envVars); envVars ["MONO_OPTIONS"] = "--debug"; } var ncmd = new NativeExecutionCommand( xspPath, cmd.XspParameters.GetXspParameters() + " --nonstop", cmd.BaseDirectory, envVars); return(Runtime.ProcessService.GetDefaultExecutionHandler(ncmd).Execute(ncmd, console)); } // Set DEVPATH when running on Windows (notice that this has no effect unless // <developmentMode developerInstallation="true" /> is set in xsp2.exe.config var evars = cmd.TargetRuntime.GetToolsExecutionEnvironment(cmd.TargetFramework).Variables; if (cmd.TargetRuntime is MsNetTargetRuntime) { evars["DEVPATH"] = Path.GetDirectoryName(xspPath); } var netCmd = new DotNetExecutionCommand( xspPath, cmd.XspParameters.GetXspParameters() + " --nonstop", cmd.BaseDirectory, evars); netCmd.DebugMode = cmd.DebugMode; return(cmd.TargetRuntime.GetExecutionHandler().Execute(netCmd, console)); }
public DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command) { NativeExecutionCommand pec = (NativeExecutionCommand)command; DebuggerStartInfo startInfo = new DebuggerStartInfo(); startInfo.Command = pec.Command; startInfo.Arguments = pec.Arguments; startInfo.WorkingDirectory = pec.WorkingDirectory; if (pec.EnvironmentVariables.Count > 0) { foreach (KeyValuePair <string, string> val in pec.EnvironmentVariables) { startInfo.EnvironmentVariables[val.Key] = val.Value; } } return(startInfo); }
internal static void ExecuteProject(DubProject prj, IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) { var conf = prj.GetConfiguration(configuration) as DubProjectConfiguration; IConsole console; if (conf.ExternalConsole) { console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput); } else { console = context.ConsoleFactory.CreateConsole(true); } var operationMonitor = new AggregatedOperationMonitor(monitor); var sr = new StringBuilder("run"); Instance.BuildCommonArgAppendix(sr, prj, configuration); try { var cmd = new NativeExecutionCommand(Instance.DubExecutable, sr.ToString(), prj.BaseDirectory.ToString()); if (!context.ExecutionHandler.CanExecute(cmd)) { monitor.ReportError("Cannot execute \"" + "\". The selected execution mode is not supported for Dub projects.", null); return; } var op = context.ExecutionHandler.Execute(cmd, console); operationMonitor.AddOperation(op); op.WaitForCompleted(); monitor.Log.WriteLine(Instance.DubExecutable + " exited with code: {0}", op.ExitCode); } catch (Exception ex) { monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex); } finally { operationMonitor.Dispose(); console.Dispose(); } }
public override IProcessAsyncOperation Execute (ExecutionCommand command, IConsole console) { DotNetExecutionCommand dotcmd = (DotNetExecutionCommand) command; string tempFile = Path.GetTempFileName (); string snapshotFile = profiler.GetSnapshotFileName (dotcmd.Command, tempFile); string args = string.Format ("--profile={2}:{3} --debug \"{0}\" {1}", dotcmd.Command, dotcmd.Arguments, profiler.Identifier, tempFile); NativeExecutionCommand cmd = new NativeExecutionCommand ("mono", args, dotcmd.WorkingDirectory, dotcmd.EnvironmentVariables); IProcessAsyncOperation pao = base.Execute (cmd, console); ProfilingService.ActiveProfiler = profiler; ProfilingContext profContext = new ProfilingContext (pao, snapshotFile); profiler.Start (profContext); return pao; }
public override ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console) { var ceCmd = (CryEngineGameExecutionCommand)command; var ceTarget = ceCmd.Target as CryEngineExecutionTarget; var launcherPath = ceTarget != null ? ceTarget.LauncherPath : ceCmd.CryEngineParameters.LauncherPath; var workingDirectory = Path.GetDirectoryName(launcherPath); var arguments = $"-project {ceCmd.CryEngineParameters.ProjectPath}"; if (ceCmd.CryEngineParameters.CommandArguments != null) { arguments += " " + ceCmd.CryEngineParameters.CommandArguments; } if (ceTarget != null && ceTarget.CommandArguments != null) { arguments += " " + ceTarget.CommandArguments; } var nativeCmd = new NativeExecutionCommand(launcherPath, arguments, workingDirectory); return(base.Execute(nativeCmd, console)); }
private static ExecutionCommand CreateExecutionCommand(HaxeProject project, HaxeProjectConfiguration configuration) { string hxmlPath = Path.GetFullPath(project.TargetHXMLFile); if (!File.Exists(hxmlPath)) { hxmlPath = Path.Combine(project.BaseDirectory, project.TargetHXMLFile); } string hxml = File.ReadAllText(hxmlPath); hxml = hxml.Replace(Environment.NewLine, " "); string[] hxmlArgs = hxml.Split(' '); List <string> platforms = new List <string> (); List <string> platformOutputs = new List <string> (); bool addNext = false; bool nextIsMain = false; string main = ""; foreach (string hxmlArg in hxmlArgs) { if (addNext) { if (!hxmlArg.StartsWith("-")) { if (nextIsMain) { main = hxmlArg; nextIsMain = false; } else { platformOutputs.Add(hxmlArg); } } else { if (!nextIsMain) { platforms.RemoveAt(platforms.Count - 1); } } } addNext = true; switch (hxmlArg) { case "-cpp": platforms.Add("cpp"); break; case "-swf": case "-swf9": platforms.Add("flash"); break; case "-js": platforms.Add("js"); break; case "-neko": platforms.Add("neko"); break; case "-php": platforms.Add("php"); break; case "-main": nextIsMain = true; break; default: addNext = false; break; } } int i = 0; //for (int i = 0; i < platforms.Count; i++) //{ string platform = platforms[i]; string output = platformOutputs[i]; if (platform == "cpp" || platform == "neko") { if (platform == "cpp") { output = Path.Combine(output, main); if (configuration.DebugMode) { output += "-debug"; } } if (!File.Exists(Path.GetFullPath(output))) { output = Path.Combine(project.BaseDirectory, output); } string exe = ""; string args = ""; if (platform == "cpp") { exe = output; } else { exe = "neko"; args = "\"" + output + "\""; } NativeExecutionCommand cmd = new NativeExecutionCommand(exe); cmd.Arguments = args; cmd.WorkingDirectory = Path.GetDirectoryName(output); if (configuration.DebugMode) { cmd.EnvironmentVariables.Add("HXCPP_DEBUG_HOST", "gdb"); cmd.EnvironmentVariables.Add("HXCPP_DEBUG", "1"); } //cmd.WorkingDirectory = project.BaseDirectory.FullPath; //MonoDevelop.Ide.MessageService.ShowMessage (cmd.Command); //MonoDevelop.Ide.MessageService.ShowMessage (cmd.Arguments); //MonoDevelop.Ide.MessageService.ShowMessage (cmd.WorkingDirectory); return(cmd); } else if (platform == "flash" || platform == "js") { if (!File.Exists(Path.GetFullPath(output))) { output = Path.Combine(project.BaseDirectory, output); } if (platform == "js") { output = Path.Combine(Path.GetDirectoryName(output), "index.html"); } //string target = output; switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: //target = "open \"" + output + "\""; break; case PlatformID.Unix: //target = "xdg-open \"" + output + "\""; break; } ProcessExecutionCommand cmd = new ProcessExecutionCommand(); cmd.Command = output; return(cmd); } //} return(null); }