MS Build 未在构建服务器上编译 MS 测试项目
我正在使用 TFS 2008 和 VS 2010。将 MS Test 项目添加到我的解决方案后,我开始在构建服务器上收到以下错误。
UnitTest1.cs(5,40): 错误 CS0234: 类型或命名空间名称 命名空间中不存在“UnitTesting” “Microsoft.VisualStudio.TestTools”(您是否缺少程序集 参考?)UnitTest1.cs(22,17):错误CS0246:类型或命名空间 无法找到名称“TestContext”(您是否缺少使用 指令还是程序集引用?)UnitTest1.cs(28,16):错误 CS0246:找不到类型或命名空间名称“TestContext” (您是否缺少 using 指令或程序集引用?) UnitTest1.cs(62,10): 错误 CS0246: 类型或命名空间名称 找不到“TestMethod”(您是否缺少 using 指令或 程序集引用?)UnitTest1.cs(62,10):错误CS0246:类型或 找不到命名空间名称“TestMethodAttribute”(您是吗? 缺少 using 指令或程序集引用?) UnitTest1.cs(12,6):错误CS0246:类型或命名空间名称 找不到“TestClass”(您是否缺少 using 指令或 程序集引用?)UnitTest1.cs(12,6):错误CS0246:类型或 找不到名称空间名称“TestClassAttribute”(您是吗? 缺少 using 指令或程序集引用?)执行完毕 任务“Csc”——失败。
我在构建服务器上安装了 VS 2010,但仍然出现相同的错误。
I am using TFS 2008 and VS 2010. After adding a MS Test project to my solution I started receiving following errors on the Build server.
UnitTest1.cs(5,40): error CS0234: The type or namespace name
'UnitTesting' does not exist in the namespace
'Microsoft.VisualStudio.TestTools' (are you missing an assembly
reference?) UnitTest1.cs(22,17): error CS0246: The type or namespace
name 'TestContext' could not be found (are you missing a using
directive or an assembly reference?) UnitTest1.cs(28,16): error
CS0246: The type or namespace name 'TestContext' could not be found
(are you missing a using directive or an assembly reference?)
UnitTest1.cs(62,10): error CS0246: The type or namespace name
'TestMethod' could not be found (are you missing a using directive or
an assembly reference?) UnitTest1.cs(62,10): error CS0246: The type or
namespace name 'TestMethodAttribute' could not be found (are you
missing a using directive or an assembly reference?)
UnitTest1.cs(12,6): error CS0246: The type or namespace name
'TestClass' could not be found (are you missing a using directive or
an assembly reference?) UnitTest1.cs(12,6): error CS0246: The type or
namespace name 'TestClassAttribute' could not be found (are you
missing a using directive or an assembly reference?) Done executing
task "Csc" -- FAILED.
I installed VS 2010 on the build server but still the same errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题出在您的测试项目中。您引用了一些尚未部署到构建服务器的程序集。此外,您也不能通过简单地复制并粘贴到 GAC 或工作目录来做到这一点。
最好、最简单的方法是安装 Visual studio 2010 构建服务器中的代理。
它是免费的,可以从 MS 网站下载。通过安装代理,它将安装编译甚至运行 MSTest 项目所需的所有库。
The problem is in your test projects. you're referencing to some assemblies which haven't been deployed to the Build Server. Also you cannot do that by simply copy and paste to GAC or working directory.
The best and easiest way to do that is installing Visual studio 2010 Agents in the build server.
It's free and it can be downloaded from MS web site. By installing the agents, it will install all the required libraries for compiling and even running the MSTest projects.
您可以检查您是否使用了正确的 MSBuild。就我而言,当我收到以下消息时:
我们必须确保我们正在运行正确的 MSBuild 版本。
这还修复了
Microsoft.VisualStudio.QualityTools.UnitTestFramework
.dll 的一些问题You could check if you are using correct MSBuild. In my case, when I receive messages such as:
We had to be sure we are running correct MSBuild version.
That also fixes some issues with
Microsoft.VisualStudio.QualityTools.UnitTestFramework
.dll您的标签提到了 VS2010 和 TFS2008。默认情况下,单元测试项目设置为目标 .NET 4.0,而 Team Build 2008 将不知道如何处理这些项目。您应该将测试项目设置为面向 .NET 3.5(仅当您安装了 VS2010 SP1 时才能完成)。或者将 TFS 2008 升级到 TFS2010。
如果要使用 TFS 2008 运行测试工具,还应该在生成代理上安装 Visual Studio Team Developer 或 Suite。 Visual Studio 2010 不会帮助你。
Your tags mention VS2010 and TFS2008. By default unit test projects are set to target .NET 4.0 and Team Build 2008 won't know how to handle those. You should set your test projects to target .NET 3.5 (can only be done if you've installed VS2010 SP1). Or upgrade TFS 2008 to TFS2010.
If you want to run the testing tools with TFS 2008, you should also install Visual Studio Team Developer or Suite on the build agent. Visual Studio 2010 won't help you.