c# - .dll 引用在 Debug模式下正确加载到 c# 项目中,但在 Release模式下找不到 namespace

标签 c# dll nunit teamcity

我正在为我的公司设置一个 CI 服务器并集成单元测试。我选择使用 TeamCity 和 NUnit,因为它们在我过去工作过的其他组织中运行良好。

我已启动并运行 TeamCity,目前我只创建了一个测试单元测试项目,因此我可以验证 TeamCity 是否正确处理了我的 NUnit 配置。在我的项目中,我添加了对 nunit.framework.dll 的引用,它位于我的解决方案根目录中的一个文件夹中。当我提交要测试的解决方案时,这是我在 TeamCity 中构建步骤得到的输出:

[10:45:35][Csc] UnitTesting.cs(5, 7): error CS0246: The type or namespace name 'NUnit' could not be found (are you missing a using directive or an assembly reference?)

[10:45:35][Csc] UnitTesting.cs(16, 10): error CS0246: The type or namespace name 'Test' could not be found (are you missing a using directive or an assembly reference?)

[10:45:35][Csc] UnitTesting.cs(16, 10): error CS0246: The type or namespace name 'TestAttribute' could not be found (are you missing a using directive or an assembly reference?)

[10:45:35][Csc] UnitTesting.cs(13, 6): error CS0246: The type or namespace name 'TestFixture' could not be found (are you missing a using directive or an assembly reference?)

[10:45:35][Csc] UnitTesting.cs(13, 6): error CS0246: The type or namespace name 'TestFixtureAttribute' could not be found (are you missing a using directive or an assembly reference?)

当我回到我的 IDE 时,我能够在没有看到这些错误消息的情况下构建解决方案。直到我切换到发布配置。切换配置并构建解决方案后,我在 IDE 中收到的消息与从 TeamCity 收到的消息相同。

我尝试再次将 .dll 文件添加到我的项目中,但 Visual Studio 提示该引用已经存在并阻止我再次添加它。

什么给了?

最佳答案

几乎这里发生的事情是:Visual Studio 忘记了正在发生的事情并且无缘无故地与现实失去联系并且不知道在哪里寻找 .dll。我不知道为什么它只发生在发布配置中,但我删除了引用并重新添加它,一切都很好。

关于c# - .dll 引用在 Debug模式下正确加载到 c# 项目中,但在 Release模式下找不到 namespace ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21142239/

相关文章:

c# - 多种属性合二为一?

c# - 如何测试 QueueClient 是否可以成功连接到 Azure 服务总线队列?

C++,dll的多个实例,单例

C# 导入 C++ dll

c# - 如何使用 asp.net mvc 和单元测试组织代码和测试

c# - Entity Framework 连接无法识别创建的临时表

C# - StringDictionary - 如何使用单个循环获取键和值?

c - 使用 LoadLibraryExA(...,...,LOAD_LIBRARY_AS_DATAFILE) 时 GetModuleInformation 失败?

nunit - 使用 nunit 和 TestCaseSource 和 TestCaseData 设置复杂的行测试

c# - NUnit 是 Selenium 测试的错误选择吗?