public VSProcess GetVSProcessWithoutSolution() { VSProcess.Initialize(vsProcesses); foreach (var vsProcess in vsProcesses) { if (!vsProcess.HasOpenSolution) { return(vsProcess); } } return(null); }
public VSProcess GetVSProcessWithSolution(string solutionFilePath) { VSProcess.Initialize(vsProcesses); foreach (var vsProcess in vsProcesses) { if (vsProcess.HasOpenSolution && vsProcess.Solution.FullName == solutionFilePath) { return(vsProcess); } } return(null); }
public static void GetAllRunningInstances(ref List <VSProcess> runningVSInstances) { IDictionary <string, object> runningObjects = ProcessFinder.GetRunningObjectTables(); foreach (string objectName in runningObjects.Keys) { if (objectName.StartsWith("!VisualStudio.DTE")) { var vsProcess = VSProcess.FromROT(objectName, runningObjects[objectName]); if (vsProcess != null) { runningVSInstances.Add(vsProcess); } } } }
public void PrintVSInstance(VSProcess vsProcess) { if (vsProcess == null || !vsProcess.IsInitialized) { return; } Console.WriteLine($"{vsProcess.ROTName}"); if (vsProcess.HasOpenSolution) { Console.WriteLine($"\t{vsProcess.Solution.FullName}"); } else { Console.WriteLine($"\tNo solution open"); } }
public static VSProcess GetInstanceByProcessId(int processId) { IDictionary <string, object> runningObjects = ProcessFinder.GetRunningObjectTables(); foreach (string objectName in runningObjects.Keys) { if (objectName.StartsWith("!VisualStudio.DTE") && objectName.EndsWith($"{processId}")) { var vsProcess = VSProcess.FromROT(objectName, runningObjects[objectName]); if (vsProcess != null) { return(vsProcess); } } } return(null); }
public static void Initialize(VSProcess vsProcess) { vsProcess?.Initialize(); }