为什么我无法使用项目解决方案文件在 Msbuild Teamcity 中构建测试项目?

Why i cannot build the test project in Msbuild Teamcity using the project solution file?

UnitTest1.cs(131,10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)

16:42:40 UnitTest1.cs(131,10):错误 CS0246:找不到类型或命名空间名称 'TestMethod'(是否缺少 using 指令或程序集引用?)

16:42:40 UnitTest1.cs(144,10):错误 CS0246:找不到类型或命名空间名称 'TestMethodAttribute'(是否缺少 using 指令或程序集引用?)

Why i cannot build the test project in Msbuild Teamcity using the project solution file?

首先你要确定你的测试项目是否可以在本地成功构建。

然后,请遵循以下建议:

建议

首先,在Teamcity 9.1.5之前,您应该在构建代理上安装Microsoft Visual Studio edition并确保安装正确的版本。请参阅 this official document

TeamCity 9.1.5以来,Visual Studio Test Runner 支持 Visual Studio 代理机器上安装的测试代理(Microsoft Visual Studio不再需要)。可以参考this link.

其次,您应该在构建步骤之前在 VCS 上恢复 nuget 包。