Visual studio 2015 TeamCity无法启动MSTest.exe或vstest.console.exe

Visual studio 2015 TeamCity无法启动MSTest.exe或vstest.console.exe,visual-studio-2015,teamcity,mstest,teamcity-9.0,vstest.console.exe,Visual Studio 2015,Teamcity,Mstest,Teamcity 9.0,Vstest.console.exe,当我试图通过teamcity运行单元测试时,我遇到了这个错误 MyTeamCity版本是9.1,我使用的是Visual Studio 2015。 如果更改MSTest.exe或vstest.console.exe的名称,则会引发另一个查找文件的错误。此外,我认为问题不在于我的项目版本,因为我可以通过命令行使用我的测试dll运行MSTest.exe和vstest.console.exe。我已经尝试安装visual studio 2013测试代理,但在尝试运行MSTest.exe时遇到了相同的错误

当我试图通过teamcity运行单元测试时,我遇到了这个错误 MyTeamCity版本是9.1,我使用的是Visual Studio 2015。 如果更改MSTest.exe或vstest.console.exe的名称,则会引发另一个查找文件的错误。此外,我认为问题不在于我的项目版本,因为我可以通过命令行使用我的测试dll运行MSTest.exe和vstest.console.exe。我已经尝试安装visual studio 2013测试代理,但在尝试运行MSTest.exe时遇到了相同的错误

MSTest executable: C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\MSTest.exe Command line params: [[/testcontainer:C:\TeamCity\buildAgent\work\6028ae3d00a3d06d\WebApi.Test\bin\Release\WebApi.Test.dll]
[/resultsfile:C:\TeamCity\buildAgent\temp\buildTmp\mstest_results_1461330948659.teamcity.trx]]
Starting:
C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe
#TeamCityImplicit in directory: C:\TeamCity\buildAgent\work\6028ae3d00a3d06d 2016-04-22 16:15:49,315
[13520] ERROR
JetBrains.TeamCity.GenericProcessSupport.GenericProcessArguments -
Failed Platform from: NATIVE, Failed to parse PlatformVersion: NATIVE
JetBrains.TeamCity.Utils.CommandLineParseException: Failed to parse
PlatformVersion: NATIVE at
JetBrains.TeamCity.Utils.Runtime.ParseUtil.ParseEnvironment(String
value) in
c:\BuildAgent\work\ad31cec0a1b0f083\src\Utils\src\Runtime\ParseUtil.cs:line
36 at
JetBrains.TeamCity.GenericProcessSupport.GenericProcessArguments.set_RuntimeVersionInternal(String
value) in
c:\BuildAgent\work\ad31cec0a1b0f083\src\GenericProcessSupport\src\GenericProcessArguments.cs:line
70 2016-04-22 16:15:49,929 [32004] ERROR
***JetBrains.TeamCity.Utils.Runtime.ParseUtil - Failed to load assembly
from file C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\MSTest.exe: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.*** (Exception
from HRESULT: 0x8013101B) System.BadImageFormatException: This
assembly is built by a runtime newer than the currently loaded runtime
and cannot be loaded. (Exception from HRESULT: 0x8013101B) at
System.Reflection.Assembly.nLoadFile(String path, Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path) at
JetBrains.TeamCity.Utils.Runtime.ParseUtil.LoadAssembly(String value)
in
c:\BuildAgent\work\ad31cec0a1b0f083\src\Utils\src\Runtime\ParseUtil.cs:line
110 Failed to start process due to error:
JetBrains.TeamCity.Utils.CommandLineParseException: Failed to load
assembly from file C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\MSTest.exe: ***This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (Exception
from HRESULT: 0x8013101B)*** ---> System.BadImageFormatException: This
assembly is built by a runtime newer than the currently loaded runtime
and cannot be loaded. (Exception from HRESULT: 0x8013101B) at
System.Reflection.Assembly.nLoadFile(String path, Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path) at
JetBrains.TeamCity.Utils.Runtime.ParseUtil.LoadAssembly(String value)
in c:\BuildAgent\work\ad31cec0a1b0f083\src\Utils\src\Runtime\ParseUtil.cs:line
110
--- End of inner exception stack trace --- at JetBrains.TeamCity.Utils.Runtime.ParseUtil.LoadAssembly(String value)
in
c:\BuildAgent\work\ad31cec0a1b0f083\src\Utils\src\Runtime\ParseUtil.cs:line
124 at
JetBrains.TeamCity.PlatformProcessRunner.PlatformSwitchBase.Main2(String[]
args) in
c:\BuildAgent\work\ad31cec0a1b0f083\src\PlatformProcessRunner\src\PlatformSwitchBase.cs:line
66 at
JetBrains.TeamCity.PlatformProcessRunner.PlatformSwitchBase.Main(String[]
args) in
c:\BuildAgent\work\ad31cec0a1b0f083\src\PlatformProcessRunner\src\PlatformSwitchBase.cs:line
24 Process exited with code -1
无论怎样,这都很好:

C:\Users\*****>"C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\ MSTest.exe" /testcontainer:"C:/TeamCity/buildAgent/work/6028ae3d00a3d06d/WebApi.
Test/bin/Release/WebApi.Test.dll"
/resultsfile:C:\TeamCity\buildAgent\temp\build
Tmp\mstest_results_1461330948659.teamcity.trx
当我尝试使用vstest.console.exe时,出现以下错误:

VSTest will report tests to TeamCity after run VSTest executable:
C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
Command line params:
[[C:\TeamCity\buildAgent\work\6028ae3d00a3d06d\WebApi.Test\bin\Release\WebApi.Test.dll]
[/Logger:trx] [/Platform:x64]] Starting:
 C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe
#TeamCityImplicit in directory: C:\TeamCity\buildAgent\work\6028ae3d00a3d06d 2016-04-22 16:37:54,082
[8032] ERROR
JetBrains.TeamCity.GenericProcessSupport.GenericProcessArguments -
Failed Platform from: NATIVE, Failed to parse PlatformVersion: NATIVE
JetBrains.TeamCity.Utils.CommandLineParseException: Failed to parse
PlatformVersion: NATIVE at
JetBrains.TeamCity.Utils.Runtime.ParseUtil.ParseEnvironment(String
value) in
c:\BuildAgent\work\ad31cec0a1b0f083\src\Utils\src\Runtime\ParseUtil.cs:line
36 at
JetBrains.TeamCity.GenericProcessSupport.GenericProcessArguments.set_RuntimeVersionInternal(String
value) in
c:\BuildAgent\work\ad31cec0a1b0f083\src\GenericProcessSupport\src\GenericProcessArguments.cs:line
70 2016-04-22 16:37:54,527 [21112] ERROR
JetBrains.TeamCity.Utils.Runtime.ParseUtil - Failed to load assembly
from file C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe:
***The module was expected to contain an assembly manifest. (Exception
from HRESULT: 0x80131018) System.BadImageFormatException: The module
was expected to contain an assembly manifest. (Exception from HRESULT:
0x80131018)*** at System.Reflection.Assembly.nLoadFile(String path,
Evidence evidence) at System.Reflection.Assembly.LoadFile(String path)
at JetBrains.TeamCity.Utils.Runtime.ParseUtil.LoadAssembly(String
value) in
c:\BuildAgent\work\ad31cec0a1b0f083\src\Utils\src\Runtime\ParseUtil.cs:line
110 Failed to start process due to error:
JetBrains.TeamCity.Utils.CommandLineParseException: Failed to load
assembly from file C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe:
The module was expected to contain an assembly manifest. (Exception
from HRESULT: 0x80131018) ---> System.BadImageFormatException: The
module was expected to contain an assembly manifest. (Exception from
HRESULT: 0x80131018) at System.Reflection.Assembly.nLoadFile(String
path, Evidence evidence) at System.Reflection.Assembly.LoadFile(String
path) at
JetBrains.TeamCity.Utils.Runtime.ParseUtil.LoadAssembly(String value)
in
c:\BuildAgent\work\ad31cec0a1b0f083\src\Utils\src\Runtime\ParseUtil.cs:line
110
--- End of inner exception stack trace --- at JetBrains.TeamCity.Utils.Runtime.ParseUtil.LoadAssembly(String value)
in
c:\BuildAgent\work\ad31cec0a1b0f083\src\Utils\src\Runtime\ParseUtil.cs:line
124 at
JetBrains.TeamCity.PlatformProcessRunner.PlatformSwitchBase.Main2(String[]
args) in
c:\BuildAgent\work\ad31cec0a1b0f083\src\PlatformProcessRunner\src\PlatformSwitchBase.cs:line
66 at
JetBrains.TeamCity.PlatformProcessRunner.PlatformSwitchBase.Main(String[]
args) in
c:\BuildAgent\work\ad31cec0a1b0f083\src\PlatformProcessRunner\src\PlatformSwitchBase.cs:line
24 Process exited with code -1
另一方面,这可以通过控制台正常工作:

C:\Users\*****>"C:/Program Files (x86)/Microsoft Visual Studio
14.0/Common7/IDE/CommonExtensions/Microsoft/TestWindow/vstest.console.exe"
C:/TeamCity/buildAgent
/work/6028ae3d00a3d06d/WebApi.Test/bin/Release/WebApi.Test.dll

您是否尝试在同一用户下的同一代理上通过命令行运行同一生成?查找更多详细信息。是的,它可以通过命令行正常工作,正如我在我的问题中提到的。您是否在与TeamCity agent在工作目录中运行的同一台计算机上以及在同一用户下运行了它?是的,我确实这样做了。