public XspSession(XspOptions options, string remote_path, List <string> mono_args, StringDictionary env_vars) { this.options = options; var mono = Utilities.GetMonoExecutable(); var current = Assembly.GetCallingAssembly(); var current_dir = Path.GetDirectoryName(current.Location); Console.WriteLine(current_dir); var webserver = Path.Combine(current_dir, "MonoTools.WebServer.exe"); List <string> args = new List <string> (); args.Add("--debug"); args.AddRange(mono_args); args.Add(string.Format("\"{0}\"", webserver)); var process_args = string.Join(" ", args.ToArray()); psi = new ProcessStartInfo(mono, process_args); psi.UseShellExecute = false; psi.RedirectStandardInput = true; psi.RedirectStandardOutput = true; }
protected virtual XspSession StartXspSession(XmlDocument options) { // See if VS sent us a XspOptions var xsp_node = options.SelectSingleNode("/options/xsp-options"); if (xsp_node != null) { xsp_options = new XspOptions(xsp_node); } else { xsp_options = new XspOptions( host, MonoToolsConfigurationManager.ApplicationPortRangeStart, MonoToolsConfigurationManager.ApplicationPortRangeEnd); } xsp_options.LocalDirectory = RemotePath; // Set debug = true and RemoteErrors = off in web.config bool custom_errors_off = false; if (xsp_options.CustomErrorsOff != null) { custom_errors_off = (bool)xsp_options.CustomErrorsOff; } if (options.DocumentElement["customerrorsoff"] != null) { custom_errors_off = bool.Parse(options.DocumentElement["customerrorsoff"].InnerText); } Utilities.ModifyWebConfig(RemotePath, true, custom_errors_off); // Get environment variables and arguments for Mono StringDictionary env_vars = new StringDictionary(); SetEnvironmentVariables(env_vars, options); List <string> mono_args = new List <string> (); AddMonoArguments(mono_args); if (options.DocumentElement["monoarguments"] != null) { mono_args.Add(options.DocumentElement["monoarguments"].InnerText); } // Fire up the session xsp = new XspSession(xsp_options, RemotePath, mono_args, env_vars); if (xsp.Start() == false) { return(null); } WaitForXspPort(); return(xsp); }
public MonoWebSource(XspOptions options) : base(IPAddress.Any, 0) { this.Options = options; IPAddress address; if (options.BindAddress.Equals(IPAddress.Any)) { address = Dns.GetHostAddresses(Dns.GetHostName())[0]; } else { address = options.BindAddress; } BindAddress = address; }
public static void Main(string[] args) { XmlDocument doc = new XmlDocument(); doc.Load(Console.In); XmlNode node = doc.SelectSingleNode("/xsp-options"); var opts = new XspOptions(node); var source = new MonoWebSource(opts); Environment.CurrentDirectory = opts.LocalDirectory; var server = new ApplicationServer(source); server.AddApplicationsFromCommandLine("/:."); XspResult result; try { if (server.Start(false)) { result = new XspResult(source.EndPoint); } else { result = new XspResult("Cannot start xsp."); } } catch (Exception ex) { var msg = String.Format("Cannot start xsp: {0}", ex.Message); result = new XspResult(msg); } Console.Out.WriteLine(result.ToXml()); Console.Out.Flush(); }