【问题标题】:MSTest workflow activity execution errorMSTest 工作流活动执行错误
【发布时间】:2026-02-08 18:30:01
【问题描述】:

为我的 Team Build 2010 执行 MSTest 工作流活动时出现下一个输出日志错误:

MSTest
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe /nologo /usestderr /testcontainer:"D:\TFS\Builds\MyProyect\Debug\W_DEBUG\W_DEBUG_20111214.15\Binary\OrderedTest1.orderedtest" /publish:"http://localhost:8080/tfs/DefaultCollection" /publishbuild:"vstfs:///Build/Build/2550" /teamproject:"MyProyect" /platform:"Mixed Platforms" /flavor:"Debug" 
 The directory name is invalid

如果我在本地构建服务器上执行该命令(用双引号括起来 MSTest.exe 路径),它会完美运行。

如何设置 MSTest 活动的绝对路径?我尝试将 MSTest ToolPath 属性设置为:

System.IO.Path.GetFullPath("C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\")

不成功。

提前致谢

【问题讨论】:

  • 您是否在构建服务器中安装了 Visual Studio?没有它,MsTest 就不存在。
  • 正如我所说,如果我在本地(在构建服务器中)运行该命令,它会完美运行。事实上,我已经将包含“MSTest.exe”的整个文件夹移动到其他没有空格的路径(例如 C:\Common7\IDE\...)并且错误仍然存​​在。这不是路径空间的东西,我不知道为什么会这样。
  • 有人对此有解决方案吗?

标签: visual-studio-2010 workflow mstest tfsbuild


【解决方案1】:

我通过在构建定义中使用以下命令解决了这个问题:

<Exec Command="&quot;%VS100COMNTOOLS%\..\IDE\MSTest.exe&quot; /testcontainer:

以这种方式使用变量:

%VS100COMNTOOLS%

(或%VS90COMNTOOLS% for Visual Studio 2008)我不需要向构建服务器的 PATH 环境变量添加任何内容,mstest.exe 已成功解析。

【讨论】:

    【解决方案2】:

    我遇到的问题是运行它的进程以 SYSTEM 运行,但是当 MSTest 运行时,它似乎以 MACHINENAME$ 运行,将所有者更改为本地用户解决了问题并阻止 MSTest 退出。

    【讨论】: