从 TeamCity 运行 NUnit 测试时出现 FileNotFoundException
我正在使用内置的 TeamCity NUnit 运行程序来运行存储在 .DLL 文件中的测试。
我的 .DLL 正在引用同一文件夹中存在的其他 DLL。
运行这些时,我收到引用的 DLL 的 FileNotFoundException。
我该如何解决这个问题?我在想 TC NUnit 运行程序可能正在使用其他一些目录作为主应用程序执行文件夹,从而防止实际驻留在测试 DLL 旁边的文件无法正确加载,但还无法证明这一说法...
其他人遇到过这种行为吗?
I am using the built in TeamCity NUnit runner to run tests stored in .DLL files.
My .DLLs are referencing other DLLs which are present in the same folder.
When running these, i am getting a FileNotFoundException for the referenced DLLs.
How can i fix this? I am thinking perhaps the TC NUnit runner is using some other dir as the main app execution folder, and thus preventing from files that are actually residing next to the test DLL to not load properly, but cannot prove this claim yet...
Anyone else encountered this behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的,问题解决了,这确实是愚蠢和尴尬的:
我已经设置了 NUnit 测试运行程序来执行这些测试:
这意味着它将包括来自
/bin/Debug/
以及其他文件夹的测试,例如obj/
在这些文件夹中,当然不包含任何引用,这使得相同的测试运行两次,其中一些当然会失败!
OK the problem is solved and it is indeed silly and embarrassing:
I have set the NUnit test runner to execute these tests:
This means that it will include tests from
/bin/Debug/
and also from other folders, such asobj/
In these folders, no references are included of course, making the same tests run twice and some of these fail of course!
路径与构建签出目录相关,而不与任何工作目录相关。如果您需要其他路径,请使用
%reference%
语法通过目录路径引用 TeamCity 属性。你在Windows下运行它吗?您使用 TeamCity 6.5 吗?如果这没有帮助,请免费联系 [电子邮件受保护]
Paths are related to build checkout directory, not to any working directory. If you need another paths, use
%reference%
syntax to refer to TeamCity property with a directory path. Do you run it under Windows? Do you use TeamCity 6.5?If that does not help, feed free to contact [email protected]
就我而言,丢失的 DLL 是一个本机库,并且无法加载它,因为构建代理上安装的 VC 运行时版本不正确。我的解决方案是将运行时DLL(位于'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\redist\x86\Microsoft.VC110.CRT')直接添加到项目中(构建操作=内容,复制到输出目录=始终复制)。这也使得安装更加友好。
希望这有帮助。
In my case, the missing DLL was a native library and it could not be loaded because there was an incorrect version of VC runtime installed on the build agent. My solution was to add runtime DLLs (located in 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\redist\x86\Microsoft.VC110.CRT') directly into the project (build action = Content, copy to output directory = Copy always). This also makes installation friendlier.
Hope this helps.