Beispiel #1
0
        internal void GeneratePdb2Mdb(string directoryName)
        {
            logger.Trace(directoryName);
            IEnumerable <string> files =
                Directory.GetFiles(directoryName, "*.dll")
                .Concat(Directory.GetFiles(directoryName, "*.exe"))
                .Where(x => !x.Contains("vshost"));

            logger.Trace(files.Count());

            var dirInfo = new DirectoryInfo(directoryName);

            Parallel.ForEach(files, file =>
            {
                try
                {
                    string fileNameWithoutExt = Path.GetFileNameWithoutExtension(file);
                    string pdbFile            = Path.Combine(Path.GetDirectoryName(file), fileNameWithoutExt + ".pdb");
                    if (File.Exists(pdbFile))
                    {
                        logger.Trace("Generate mdp for: " + file);
                        var procInfo = new ProcessStartInfo(MonoUtils.GetPdb2MdbPath(), Path.GetFileName(file));
                        procInfo.WorkingDirectory = dirInfo.FullName;
                        Process proc = Process.Start(procInfo);
                        proc.WaitForExit();
                    }
                }
                catch (Exception ex)
                {
                    logger.Trace(ex);
                }
            });

            logger.Trace("Transformed Debuginformation pdb2mdb");
        }
        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);
        }
        internal override Process Start(string workingDirectory)
        {
            string monoBin = MonoUtils.GetMonoPath();
            var    dirInfo = new DirectoryInfo(workingDirectory);

            string           args     = GetProcessArgs();
            ProcessStartInfo procInfo = GetProcessStartInfo(workingDirectory, monoBin);

            procInfo.Arguments = args + string.Format(" --config \"{0}.config\" \"{0}\" {1}", _targetExe, Arguments);

            _proc = Process.Start(procInfo);
            RaiseProcessStarted();
            return(_proc);
        }
Beispiel #4
0
        internal override Process Start(string workingDirectory)
        {
            string monoBin = MonoUtils.GetMonoPath();
            var    dirInfo = new DirectoryInfo(workingDirectory);

            string           args     = GetProcessArgs();
            ProcessStartInfo procInfo = GetProcessStartInfo(workingDirectory, monoBin);

            procInfo.Arguments = args + " \"" + _targetExe + "\"";

            _proc = Process.Start(procInfo);
            RaiseProcessStarted();
            return(_proc);
        }
Beispiel #5
0
        public static void EnsurePdb2MdbCallWorks()
        {
            var platform = Environment.OSVersion.Platform;

            logger.Trace($"Platform={platform}, GetMonoPath={GetMonoPath()}, GetMonoXsp4={GetMonoXsp4()}, GetPdb2MdbPath={GetPdb2MdbPath()}");

            var fileName = MonoUtils.GetPdb2MdbPath();

            try
            {
                StartProcess(fileName, string.Empty);
            }
            catch (Exception ex)
            {
                logger.Info($"Can not find and run {fileName}! Calling {nameof(AddShellScriptToMonoApp)} ...");
                if (!AddShellScriptToMonoApp())
                {
                    logger.Error(ex, $"Can not find and run {fileName}!");
                }
            }
        }
Beispiel #6
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);
        }