示例#1
0
        private static void OpenFile(string solutionFolder, string filePath, int lineNumber)
        {
            string solutionPath = Path.Combine(solutionFolder, "Boa.sln");
            {
                try
                {
                    EnvDTE80.DTE2 boa = (EnvDTE80.DTE2)Msdev.GetIDEInstance(solutionPath);

                    if (boa == null)
                    {
                        throw new Exception("BOA is not opened in Visual Studio");
                    }

                    boa.ExecuteCommand(FILE_OPENFILE, filePath);

                    ((EnvDTE.TextSelection)boa.ActiveDocument.Selection).GotoLine(lineNumber, true);

                    boa.ActiveWindow.Activate();

                    boa.MainWindow.WindowState   = vsWindowState.vsWindowStateMinimize;
                    boa.ActiveWindow.WindowState = vsWindowState.vsWindowStateMinimize;

                    boa.ActiveWindow.Activate();
                    boa.MainWindow.Activate();
                }
                catch (Exception e)
                {
                    Debug.Write(e.Message);
                }
            }
        }
        public void OpenFileInVisualStudio(string filename, int lineNumber)
        {
            try
            {
                EnvDTE80.DTE2 boa = (EnvDTE80.DTE2)Msdev.GetIDEInstance(_solutionPath);

                if (boa == null)
                {
                    boa = OpenBoaSolution();
                }

                File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "filename.txt"), filename);

                boa.ExecuteCommand("File.OpenFile", filename);

                ((EnvDTE.TextSelection)boa.ActiveDocument.Selection).GotoLine(lineNumber, true);
                boa.ActiveWindow.Activate();

                boa.MainWindow.WindowState   = vsWindowState.vsWindowStateMinimize;
                boa.ActiveWindow.WindowState = vsWindowState.vsWindowStateMinimize;

                boa.ActiveWindow.Activate();
                boa.MainWindow.Activate();
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            string solutionName  = Ask(args, 0, "Solution name?");
            string transportName = Ask(args, 1, "Transport name?");
            string target        = Ask(args, 2, "Target machine?");
            string processName   = Ask(args, 3, "Process Name?");


            var       instances  = Msdev.GetIDEInstances(true);
            var       dte        = (DTE2)instances.Find(d => d.Solution.FullName.EndsWith(solutionName, StringComparison.InvariantCultureIgnoreCase));
            var       debugger   = dte.Debugger as Debugger2;
            var       transports = debugger.Transports;
            Transport transport  = null;

            foreach (Transport loopTransport in transports)
            {
                if (loopTransport.Name.Equals(transportName, StringComparison.InvariantCultureIgnoreCase)) // "Remote (no authentication)")
                {
                    transport = loopTransport;
                    break;
                }
            }

            Processes processes = debugger.GetProcesses(transport, target); // "172.24.50.15:4022");

            foreach (Process process in processes)
            {
                if (process.Name.EndsWith(processName, StringComparison.InvariantCultureIgnoreCase))
                {
                    process.Attach();
                }
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            string solutionName = Ask(args, 0, "Solution name");
            string processName  = Ask(args, 1, "Process Name?");

            var instances = Msdev.GetIDEInstances(true);

            var dte      = (DTE2)instances.Find(d => d.Solution.FullName.EndsWith(solutionName, StringComparison.InvariantCultureIgnoreCase));
            var debugger = dte.Debugger as Debugger2;

            Processes processes = debugger.DebuggedProcesses;

            foreach (Process2 process in processes)
            {
                if (process.Name.EndsWith(processName, StringComparison.InvariantCultureIgnoreCase))
                {
                    process.Detach(false);
                }
            }
        }
        public bool IsBoaOpened()
        {
            var boa = Msdev.GetIDEInstance(_solutionPath);

            return(boa != null);
        }