【发布时间】:2016-09-07 12:18:30
【问题描述】:
我正在尝试测试使用 Visual Studio 2015 Shell(隔离)的应用程序。
为了使用 Visual Studio 测试扩展包,我找到了 older versions 的示例。它们看起来像这样:
[TestMethod]
[HostType("VS IDE")]
public void CreateVisualization()
{
TestUtils testUtils = new TestUtils();
testUtils.CloseCurrentSolution(__VSSLNSAVEOPTIONS.SLNSAVEOPT_NoSave);
testUtils.CreateProjectFromTemplate(TestContext.TestDir, "MyProjectType", "MyProjectType.zip");
testUtils.CloseCurrentSolution(__VSSLNSAVEOPTIONS.SLNSAVEOPT_NoSave);
}
我的问题是我无法调试这些测试,因为调试器没有附加到VS IDE 主机进程。有一次,我删除了 HostType-annotation,我可以设置断点并调试它,但是测试没有在正确的进程中运行。我通过在测试中编写一个无限循环然后手动附加到启动的进程(这将启用调试)来验证附加不起作用。
有没有办法在开始测试时自动将 Visual Studio 调试器附加到启动的进程,这样我就可以在没有手动“附加到进程”步骤的情况下进行调试?
编辑:
我尝试了几种解决方案,但到目前为止都没有奏效:
- How to host VS IDE during integration test via MSTest? 启动了 Visual Studio,但没有启动我的应用程序
-
Visual Studio: auto attach to a process when the process is spawned 的结果好坏参半。
Debugger.Launch有效,但仍需要接受繁琐的“选择调试器...”对话框 - Microsoft's own suggested way to automatically attach the debugger 不起作用,因为它总是在启动应用程序时启动 jit-debugger,而不仅仅是在运行(和调试)测试时。
【问题讨论】:
-
您可以尝试的另一件事是Child Process Debugging Tool。
-
@Alexander Pacha,我也分享一个解决方案,有用吗?你解决了这个问题吗?
-
查看我的编辑:我已经测试了您发布的所有解决方案(在发布之前)。到目前为止,它们都不能很好地解决附加到 VS IDE 主机适配器的特定问题。但无论如何我都很重视你的努力。
标签: c# debugging visual-studio-2015 visual-studio-extensions attach-to-process