GetMonoXsp4() public static method

public static GetMonoXsp4 ( ) : string
return string
        internal override Process Start(string workingDirectory)
        {
            string           monoBin  = MonoUtils.GetMonoXsp4();
            string           args     = GetProcessArgs();
            ProcessStartInfo procInfo = GetProcessStartInfo(workingDirectory, monoBin);

            procInfo.Arguments       = Arguments;
            procInfo.CreateNoWindow  = true;
            procInfo.UseShellExecute = false;
            procInfo.EnvironmentVariables["MONO_OPTIONS"] = args;
            procInfo.RedirectStandardOutput = true;

            _proc = Process.Start(procInfo);
            Task.Run(() =>
            {
                while (!_proc.StandardOutput.EndOfStream)
                {
                    string line = _proc.StandardOutput.ReadLine();

                    if (line.StartsWith("Listening on address"))
                    {
                        string url = line.Substring(line.IndexOf(":") + 2).Trim();
                        if (url == "0.0.0.0")
                        {
                            Url = "localhost";
                        }
                        else
                        {
                            Url = url;
                        }
                    }
                    else if (line.StartsWith("Listening on port"))
                    {
                        string port = line.Substring(line.IndexOf(":") + 2).Trim();
                        port        = port.Substring(0, port.IndexOf(" "));
                        Url        += ":" + port;

                        if (line.Contains("non-secure"))
                        {
                            Url = "http://" + Url;
                        }
                        else
                        {
                            Url = "https://" + Url;
                        }

                        RaiseProcessStarted();
                    }


                    logger.Trace(line);
                }
            });

            return(_proc);
        }
Beispiel #2
0
        private static bool AddShellScriptToMonoApp()
        {
            try
            {
                var libMonoApplicationPath = GlobalConfig.Current.LibMonoApplicationPath;
                if (string.IsNullOrWhiteSpace(libMonoApplicationPath) || !Directory.Exists(libMonoApplicationPath))
                {
                    logger.Error($"{nameof(AddShellScriptToMonoApp)}: Path {libMonoApplicationPath} from 'App.config/configuration/appSettings/{nameof(GlobalConfig.Current.LibMonoApplicationPath)}' not found!");
                    return(false);
                }

                var shellScriptInstallPath = GlobalConfig.Current.ShellScriptInstallPath;
                if (string.IsNullOrWhiteSpace(shellScriptInstallPath) || !Directory.Exists(shellScriptInstallPath))
                {
                    logger.Error($"{nameof(AddShellScriptToMonoApp)}: Path {shellScriptInstallPath} from 'App.config/configuration/appSettings/{nameof(GlobalConfig.Current.ShellScriptInstallPath)}' not found!");
                    return(false);
                }

                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    AddShellScriptToMonoApp(libMonoApplicationPath, shellScriptInstallPath, MonoUtils.GetPdb2MdbPath());
                    AddShellScriptToMonoApp(libMonoApplicationPath, shellScriptInstallPath, MonoUtils.GetMonoXsp4());
                }
                else
                {
                    logger.Error($"Workaround for missing {MonoUtils.GetPdb2MdbPath()} is implemented only for unix (support for embedded linux)!");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"{nameof(AddShellScriptToMonoApp)} failed!");
                return(false);
            }

            return(true);
        }