private EnvDTE.Solution GetSolution(ClearFilesArgs clearFilesArgs) { EnvDTE.Solution soln = TryHelper.Run(() => System.Activator.CreateInstance(Type.GetTypeFromProgID(Settings.Default.VisualStudio))) as EnvDTE.Solution; TryHelper.Run(() => { soln.DTE.MainWindow.Visible = false; }); if (!String.IsNullOrWhiteSpace(clearFilesArgs.ProyectFile)) { TryHelper.Run(() => { soln.AddFromFile(clearFilesArgs.ProyectFile); }); } else { soln.Open(clearFilesArgs.SoluctionFile); } return(soln); }
public static ITcSysManager10 AttachToXae(IConfigurationRoot configuration) { //Get JSon Settings var xaeInterfaceData = new XaeInterfaceData(); try { configuration.GetSection("XaeInterfaceData").Bind(xaeInterfaceData); } catch (Exception e) { Helpers.DebugLogger(e.Message, xaeInterfaceData.debugmode); } //Check ProgID if (xaeInterfaceData.progID == "" || xaeInterfaceData.progID == null) { Helpers.DebugLogger("No/Wrong Program Id in Settingsfile", xaeInterfaceData.debugmode); } //Check ProgID if (xaeInterfaceData.projectSolution == "" || xaeInterfaceData.projectSolution == null) { Helpers.DebugLogger("No/Wrong Projetct in Settingsfile", xaeInterfaceData.debugmode); } //Static Variables string progId = xaeInterfaceData.progID; string projectSolution = xaeInterfaceData.projectSolution; EnvDTE.DTE dte; //Get Program Type Type programType = System.Type.GetTypeFromProgID(progId, true); //Create Xae Instance if (!xaeInterfaceData.attachActiveXae) { Helpers.DebugLogger("Starting new XAE/IDE Instance ...", xaeInterfaceData.debugmode); dte = (EnvDTE.DTE)System.Activator.CreateInstance(programType); Helpers.DebugLogger("DTE Instance started: " + dte.FullName, xaeInterfaceData.debugmode); } //Attaching XAE INstance Helpers.DebugLogger("Attaching XAE/IDE ...", xaeInterfaceData.debugmode); GetRunningObjectTable(); GetIDEInstances(false, progId); dte = AttachToExistingDte(projectSolution, progId, xaeInterfaceData.debugmode); //Parameters if (dte != null) { dte.SuppressUI = false; dte.MainWindow.Visible = true; } else { Helpers.DebugLogger("Error DTE = NUll", xaeInterfaceData.debugmode); return(null); } //Open Solution EnvDTE.Solution activeSolution = dte.Solution; activeSolution.Open(projectSolution); //Wait for Solution Task.Delay(5000).Wait(); //Iterare through project and select right one EnvDTE.Project actualProject = null;; foreach (EnvDTE.Project project in activeSolution.Projects) { Helpers.DebugLogger($"Found Project: {project.Name}", xaeInterfaceData.debugmode); if (project.Name == xaeInterfaceData.projectName) { Helpers.DebugLogger($"Return Project: {project.Name}", xaeInterfaceData.debugmode); actualProject = project; break; } else { Helpers.DebugLogger($"No Project Found", xaeInterfaceData.debugmode); actualProject = null; return(null); } } if (activeSolution.IsOpen) { Helpers.DebugLogger("Solution " + activeSolution.FullName + " IsOpen", xaeInterfaceData.debugmode); } //Wait for MessageFilter Task.Delay(2000).Wait(); //TC SysManageer //ITcSysManager15 systemManager = (ITcSysManager15)actualProject.Object; if (actualProject.Object != null) { return((ITcSysManager10)actualProject.Object); } return(null); }