Когда мы открываем консоль диспетчера пакетов в любом открытом решении, он показывает все проекты этого решения. Как он загружает все проекты одного и того же решения. Когда я попытался с приведенным ниже кодом, он извлекает мне проекты первого решения, которое я открыл.
private List<Project> GetProjects()
{
var dte = (DTE)Marshal.GetActiveObject(string.Format(CultureInfo.InvariantCulture, "VisualStudio.DTE.{0}.0", targetVsVersion));
var projects = dte.Solution.OfType<Project>().ToList();
return projects;
}