コード例 #1
0
ファイル: Connect.cs プロジェクト: tgiphil/wintools
        // Run on Mono
        public bool TestInMono()
        {
            // Registry Helper Obj
            Mfconsulting.Vsprj2make.RegistryHelper regH = new RegistryHelper();

            // MonoLaunchHelper
            Mfconsulting.Vsprj2make.MonoLaunchHelper launchHlpr = new MonoLaunchHelper();

            // Web
            bool isWebProject = false;
            string aciveFileSharePath = @"C:\inetpub\wwwroot";
            string startPage = "index.aspx";
            string portForXsp = "8189";

            // Other
            string startUpProject = "";
            string projectOutputFileName = "";
            string projectOutputPathFromBase = "";
            int projectOutputType = 0;
            string projectOutputWorkingDirectory = "";

            EnvDTE.Solution thisSln = _applicationObject.Solution;

            // Run in Mono Process
            System.Diagnostics.ProcessStartInfo procInfo = new ProcessStartInfo();
            System.Diagnostics.Process monoLauncC = new System.Diagnostics.Process();
            monoLauncC.StartInfo = procInfo;

            // Get the Solution's startup project
            for (int propIdx = 1; propIdx <= thisSln.Properties.Count; propIdx++)
            {
                if (thisSln.Properties.Item(propIdx).Name.CompareTo("StartupProject") == 0)
                {
                    startUpProject = thisSln.Properties.Item(propIdx).Value.ToString();
                }
            }

            // Run in Mono
            EnvDTE.Projects projs = thisSln.Projects;
            foreach (EnvDTE.Project proj in projs)
            {
                if (startUpProject.CompareTo(proj.Name) == 0)
                {
                    foreach (EnvDTE.Property prop in proj.Properties)
                    {
                        try
                        {
                            if (prop.Name.CompareTo("ProjectType") == 0)
                            {
                                if (Convert.ToInt32(prop.Value) == 1)
                                {
                                    isWebProject = true;
                                    portForXsp = regH.Port.ToString();
                                }
                            }

                            // Web Root for XSP
                            if (prop.Name.CompareTo("ActiveFileSharePath") == 0)
                            {
                                aciveFileSharePath = prop.Value.ToString();
                            }

                            if (prop.Name.CompareTo("OutputType") == 0)
                            {
                                projectOutputType = Convert.ToInt32(prop.Value);
                            }

                            if (prop.Name.CompareTo("OutputFileName") == 0)
                            {
                                projectOutputFileName = prop.Value.ToString();
                            }

                            if (prop.Name.CompareTo("LocalPath") == 0)
                            {
                                projectOutputWorkingDirectory = prop.Value.ToString();
                            }
                        }
                        catch (System.Runtime.InteropServices.COMException exc)
                        {
                            Trace.WriteLine(String.Format("Error during RunOnMono function call:\n {0}", exc.Message));
                        }
                    }

                    // Active Configuration Properties
                    foreach (EnvDTE.Property prop in proj.ConfigurationManager.ActiveConfiguration.Properties)
                    {
                        // XSP startup page
                        if (prop.Name.CompareTo("StartPage") == 0)
                        {
                            startPage = prop.Value.ToString();
                        }

                        // Output path for non web projects
                        if (prop.Name.CompareTo("OutputPath") == 0)
                        {
                            projectOutputPathFromBase = prop.Value.ToString();
                        }
                    }

                    // If is an Executable and not a DLL or web project
                    // then launch it with monoLaunchC
                    if (isWebProject == false && (projectOutputType == 0 || projectOutputType == 1))
                    {
                        monoLauncC.StartInfo.FileName = launchHlpr.MonoLaunchCPath;
                        monoLauncC.StartInfo.WorkingDirectory = System.IO.Path.Combine(
                            projectOutputWorkingDirectory,
                            projectOutputPathFromBase);
                        monoLauncC.StartInfo.Arguments = projectOutputFileName;

                        monoLauncC.Start();
                        return true;
                    }

                    // Web Project execution and launching of XSP
                    if (isWebProject == true)
                    {
                        string startURL = String.Format(
                            "http://localhost:{0}/{1}",
                            portForXsp,
                            startPage);

                        System.Diagnostics.ProcessStartInfo procInfo1 = new ProcessStartInfo();
                        System.Diagnostics.Process launchStartPage = new System.Diagnostics.Process();
                        launchStartPage.StartInfo = procInfo1;

                        monoLauncC.StartInfo.FileName = launchHlpr.MonoLaunchCPath;
                        monoLauncC.StartInfo.WorkingDirectory = aciveFileSharePath;
                        monoLauncC.StartInfo.Arguments = String.Format(
                            "{0} --root . --port {1} --applications /:.",
                            launchHlpr.GetXspExePath(regH.XspExeSelection),
                            portForXsp
                            );

                        // Actually start XSP
                        monoLauncC.Start();

                        launchStartPage.StartInfo.UseShellExecute = true;
                        launchStartPage.StartInfo.Verb = "open";
                        launchStartPage.StartInfo.FileName = startURL;

                        // Do a little delay so XSP can launch
                        System.Threading.Thread.Sleep(1500);
                        launchStartPage.Start();
                    }
                }
            }

            /*
            string strSLNFile = _applicationObject.Solution.FileName;

            _applicationObject.StatusBar.Clear();
            outputWindowPane.OutputString("--------------------------------------\nCompile and Run in Mono: ");
            outputWindowPane.OutputString(String.Format("Solution: {0}\n", strSLNFile));

            _applicationObject.StatusBar.Text = "Attemp to build in Mono...";
            outputWindowPane.OutputString("\tAttemp to build in Mono...\n");

            // Build for Mono

            _applicationObject.StatusBar.Text = "Launch in Mono...";
            outputWindowPane.OutputString("\tLaunch in Mono...\n");

            // Lanunch in Mono
            */

            return true;
        }
コード例 #2
0
ファイル: Connect.cs プロジェクト: UIKit0/wintools
        // Run on Mono
        public bool TestInMono()
        {
            // Registry Helper Obj
            Mfconsulting.Vsprj2make.RegistryHelper regH = new RegistryHelper();

            // MonoLaunchHelper
            Mfconsulting.Vsprj2make.MonoLaunchHelper launchHlpr = new MonoLaunchHelper();

            // Web
            bool   isWebProject       = false;
            string aciveFileSharePath = @"C:\inetpub\wwwroot";
            string startPage          = "index.aspx";
            string portForXsp         = "8189";

            // Other
            string startUpProject                = "";
            string projectOutputFileName         = "";
            string projectOutputPathFromBase     = "";
            int    projectOutputType             = 0;
            string projectOutputWorkingDirectory = "";

            EnvDTE.Solution thisSln = applicationObject.Solution;

            // Run in Mono Process
            System.Diagnostics.ProcessStartInfo procInfo   = new ProcessStartInfo();
            System.Diagnostics.Process          monoLauncC = new System.Diagnostics.Process();
            monoLauncC.StartInfo = procInfo;

            // Get the Solution's startup project
            startUpProject = thisSln.Properties.Item(5).Value.ToString();

            // Run in Mono
            EnvDTE.Projects projs = thisSln.Projects;
            foreach (EnvDTE.Project proj in projs)
            {
                if (startUpProject.CompareTo(proj.Name) == 0)
                {
                    foreach (EnvDTE.Property prop in proj.Properties)
                    {
                        if (prop.Name.CompareTo("ProjectType") == 0)
                        {
                            if (Convert.ToInt32(prop.Value) == 1)
                            {
                                isWebProject = true;
                                portForXsp   = regH.Port.ToString();
                            }
                        }

                        // Web Root for XSP
                        if (prop.Name.CompareTo("ActiveFileSharePath") == 0)
                        {
                            aciveFileSharePath = prop.Value.ToString();
                        }

                        if (prop.Name.CompareTo("OutputType") == 0)
                        {
                            projectOutputType = Convert.ToInt32(prop.Value);
                        }

                        if (prop.Name.CompareTo("OutputFileName") == 0)
                        {
                            projectOutputFileName = prop.Value.ToString();
                        }

                        if (prop.Name.CompareTo("LocalPath") == 0)
                        {
                            projectOutputWorkingDirectory = prop.Value.ToString();
                        }
                    }

                    // Active Configuration Properties
                    foreach (EnvDTE.Property prop in proj.ConfigurationManager.ActiveConfiguration.Properties)
                    {
                        // XSP startup page
                        if (prop.Name.CompareTo("StartPage") == 0)
                        {
                            startPage = prop.Value.ToString();
                        }

                        // Output path for non web projects
                        if (prop.Name.CompareTo("OutputPath") == 0)
                        {
                            projectOutputPathFromBase = prop.Value.ToString();
                        }
                    }

                    // If is an Executable and not a DLL or web project
                    // then launch it with monoLaunchC
                    if (isWebProject == false && (projectOutputType == 0 || projectOutputType == 1))
                    {
                        monoLauncC.StartInfo.FileName         = launchHlpr.MonoLaunchCPath;
                        monoLauncC.StartInfo.WorkingDirectory = System.IO.Path.Combine(
                            projectOutputWorkingDirectory,
                            projectOutputPathFromBase);
                        monoLauncC.StartInfo.Arguments = projectOutputFileName;

                        monoLauncC.Start();
                        return(true);
                    }

                    // Web Project execution and launching of XSP
                    if (isWebProject == true)
                    {
                        string startURL = String.Format(
                            "http://localhost:{0}/{1}",
                            portForXsp,
                            startPage);

                        System.Diagnostics.ProcessStartInfo procInfo1       = new ProcessStartInfo();
                        System.Diagnostics.Process          launchStartPage = new System.Diagnostics.Process();
                        launchStartPage.StartInfo = procInfo1;

                        monoLauncC.StartInfo.FileName         = launchHlpr.MonoLaunchCPath;
                        monoLauncC.StartInfo.WorkingDirectory = aciveFileSharePath;
                        monoLauncC.StartInfo.Arguments        = String.Format(
                            "{0} --root . --port {1} --applications /:.",
                            launchHlpr.GetXspExePath(regH.XspExeSelection),
                            portForXsp
                            );

                        // Actually start XSP
                        monoLauncC.Start();

                        launchStartPage.StartInfo.UseShellExecute = true;
                        launchStartPage.StartInfo.Verb            = "open";
                        launchStartPage.StartInfo.FileName        = startURL;

                        // Do a little delay so XSP can launch
                        System.Threading.Thread.Sleep(1500);
                        launchStartPage.Start();
                    }
                }
            }

            /*
             * string strSLNFile = applicationObject.Solution.FileName;
             *
             * applicationObject.StatusBar.Clear();
             * outputWindowPane.OutputString("--------------------------------------\nCompile and Run in Mono: ");
             * outputWindowPane.OutputString(String.Format("Solution: {0}\n", strSLNFile));
             *
             * applicationObject.StatusBar.Text = "Attemp to build in Mono...";
             * outputWindowPane.OutputString("\tAttemp to build in Mono...\n");
             *
             * // Build for Mono
             *
             * applicationObject.StatusBar.Text = "Launch in Mono...";
             * outputWindowPane.OutputString("\tLaunch in Mono...\n");
             *
             * // Lanunch in Mono
             */

            return(true);
        }
コード例 #3
0
ファイル: Prj2MakeHelper.cs プロジェクト: tgiphil/wintools
        public string CreateMdFiles(string strInputFilePath)
        {
            string strPrj2MakeStdOut;
            System.Text.StringBuilder strbArgLine = new System.Text.StringBuilder();
            char []carSpecialCharacters = {' ','\t', ',', '*', '%', '!'};
            MonoLaunchHelper launchHlpr = new MonoLaunchHelper();

            // Build the command line parameters
            strbArgLine.AppendFormat("\"{0}\" ", m_strPrj2makePath);

            strbArgLine.Append("--csproj2prjx ");

            if(strInputFilePath.IndexOfAny(carSpecialCharacters)== -1)
            {
                strbArgLine.Append(strInputFilePath);
            }
            else
            {
                strbArgLine.AppendFormat("\"{0}\"",
                    strInputFilePath);
            }

            ProcessStartInfo pi = new ProcessStartInfo();
            pi.FileName = launchHlpr.MonoLaunchWPath;
            // pi.FileName = m_strPrj2makePath;
            pi.RedirectStandardOutput = true;
            pi.UseShellExecute = false;
            pi.CreateNoWindow = true;
            pi.Arguments = strbArgLine.ToString();
            Process p = null;
            try
            {
                p = Process.Start (pi);
            }
            catch (Exception e)
            {
                Console.WriteLine("Couldn't run prj2makesharpWin32: " + e.Message);
                return null;
            }

            strPrj2MakeStdOut = p.StandardOutput.ReadToEnd ();
            p.WaitForExit ();
            if (p.ExitCode != 0)
            {
                Console.WriteLine("Error running prj2makesharpWin32. Check the above output.");
                return null;
            }

            if (strPrj2MakeStdOut != null)
            {
                p.Close ();
                return strPrj2MakeStdOut;
            }

            p.Close ();

            return null;
        }
コード例 #4
0
ファイル: Prj2MakeHelper.cs プロジェクト: UIKit0/wintools
        public string CreateMakeFile(bool IsCsc, bool IsNmake, string strInputFilePath)
        {
            string strPrj2MakeStdOut;

            System.Text.StringBuilder strbArgLine = new System.Text.StringBuilder();
            char []          carSpecialCharacters = { ' ', '\t', ',', '*', '%', '!' };
            MonoLaunchHelper launchHlpr           = new MonoLaunchHelper();

            // Build the command line parameters
            strbArgLine.AppendFormat("\"{0}\" ", m_strPrj2makePath);

            if (IsCsc == true)
            {
                strbArgLine.Append("-c ");
            }

            if (IsNmake == true)
            {
                strbArgLine.Append("-n ");
            }

            if (strInputFilePath.IndexOfAny(carSpecialCharacters) == -1)
            {
                strbArgLine.Append(strInputFilePath);
            }
            else
            {
                strbArgLine.AppendFormat("\"{0}\"",
                                         strInputFilePath);
            }

            ProcessStartInfo pi = new ProcessStartInfo();

            pi.FileName = launchHlpr.MonoLaunchWPath;
            pi.RedirectStandardOutput = true;
            pi.UseShellExecute        = false;
            pi.CreateNoWindow         = true;
            pi.Arguments = strbArgLine.ToString();
            Process p = null;

            try
            {
                p = Process.Start(pi);
            }
            catch (Exception e)
            {
                Console.WriteLine("Couldn't run prj2makesharpWin32: " + e.Message);
                return(null);
            }

            strPrj2MakeStdOut = p.StandardOutput.ReadToEnd();
            p.WaitForExit();
            if (p.ExitCode != 0)
            {
                Console.WriteLine("Error running prj2makesharpWin32. Check the above output.");
                return(null);
            }

            if (strPrj2MakeStdOut != null)
            {
                p.Close();
                return(strPrj2MakeStdOut);
            }

            p.Close();

            return(null);
        }