visual-studio-2017 - 如何在 Visual Studio 中获取启动项目列表?
问题描述
可以启动包含多个程序集的调试会话。虽然该对话框易于设置,但如果不滚动整个项目,可能很难一眼看出选择了哪些项目。
是否可以只看到设置为开始的项目?
不要介意这是通过 Visual Studio 本身还是检查某种文件或其他。
解决方案
You can show a list of startup projects with the following command for Visual Commander (Language: C#):
public class C : VisualCommanderExt.ICommand
{
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
System.Windows.MessageBox.Show(string.Join(System.Environment.NewLine, GetStartupProjects(DTE).ToArray()));
}
System.Collections.Generic.List<string> GetStartupProjects(EnvDTE80.DTE2 dte)
{
if (dte != null && dte.Solution != null && dte.Solution.SolutionBuild != null)
{
System.Collections.Generic.List<string> result = new System.Collections.Generic.List<string>();
System.Array projects = dte.Solution.SolutionBuild.StartupProjects as System.Array;
if (projects != null)
{
foreach (string s in projects)
result.Add(s);
}
return result;
}
return null;
}
}