Can i execute Visual Studio commands like 'File.AddExistingProject' from C# code? if so how?
other sample commands..
Debug.Print varA File.CheckOutforEdit etc.
You can make use of DTE for the same, I have done something similar in past here is my code to do the same
DTE dte = null;
try
{
dte = (DTE)Marshal.GetActiveObject("VisualStudio.DTE.11.0");
}
catch
{
System.Diagnostics.Process.Start("devenv");
System.Threading.Thread.Sleep(2000);
try
{
dte = (DTE)Marshal.GetActiveObject("VisualStudio.DTE.11.0");
}
catch
{
//cant do much nw, notify
}
}
SearchResult result = (SearchResult)listFiles.SelectedItem;
dte.ExecuteCommand("File.OpenFile", result.FileName);
System.Threading.Thread.Sleep(200);
dte.ExecuteCommand("Edit.GoTo", labelLineNo.Text);
dte.MainWindow.Activate();
dte.ActiveDocument.Activate();
I hope this helps you
so you may call
dte.ExecuteCommand("File.AddExistingProject", parameters as needed);
> in immediate window followed by the expected command. Alternatively you can make use of Find/Command box to find the same. see more msdn.microsoft.com/en-us/library/1665hyw1(v=vs.80).aspx