VB.Net:运行 MSTest 时如何获取程序集的源路径?

发布于 2024-08-17 11:15:53 字数 313 浏览 1 评论 0原文

我正在尝试从 NUnit 切换到 MSTest(用于代码覆盖率选项)。 我们将应用程序的一些配置存储在文件中(应用程序通过使用相对路径找到它们,从 .dll 所在的“bin”文件夹开始)。 NUnit 在这种配置下工作得很好。 MSTest 将 .dll 复制到测试文件夹 (TestResults/name/OUT) 中。有没有办法使用 MSTest 并将其设置为不会复制 .dll(从“bin”文件夹中执行它们)?我一直在寻找这个选项,但似乎是不可能的。 另一个问题(如果复制选项不可配置)如何找到起始 .dll 路径(MSTest 在 OUT 文件夹中复制的文件的原始文件路径)?

谢谢

I'm trying to switch from NUnit to MSTest (for the Code Coverage option).
We have some of the configuration for the application stored in files (the application finds them by using a relative path, starting from the "bin" folder, where the .dlls are). NUnit worked fine with this configuration.
MSTest copies the .dlls in a test folder (TestResults/name/OUT). Is there any way to use MSTest and set it up so it won't copy the .dlls (execute them from the "bin" folder)? I've been searching for this option and it seems to be impossible.
Another question (if the copy option is not configurable) how can I find out the starting .dll path (the original file path for the file that gets copied by MSTest in the OUT folder)?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟酉 2024-08-24 11:15:53

您可以使用 System.Reflection.Assembly 类中的方法之一:

Assembly.GetExecutingAssembly()
Assembly.GetCallingAssembly()
Assembly.GetEntryAssembly()

在这些方法之间,您应该能够获得所需的所有内容。

You can use one of the methods in the System.Reflection.Assembly class:

Assembly.GetExecutingAssembly()
Assembly.GetCallingAssembly()
Assembly.GetEntryAssembly()

Between those you should be able to get all you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文