使用 TFS 构建的 vstest:System.Runtime.Remoting.RemotingException:'Object '/XXX.rem' 已断开连接或在服务器上不存在

vstest with TFS build: System.Runtime.Remoting.RemotingException: 'Object '/XXX.rem' has been disconnected or does not exist at the server

我有一个 x64 .NET 4.5.2 C# 带有单元测试的解决方案。

单元测试在我的开发机器上 运行ning 成功,但是当 运行ning 在 TFS 构建时使用以下命令:

[command]"D:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" m:\Workspace\MyApp\Tests\MyApp.Tests\bin\x64\Release\MyApp.Tests.dll /logger:trx "/TestAdapterPath:\"m:\Workspace\"" /Platform:x64

我收到以下日志:

Microsoft (R) Test Execution Command Line Tool Version 14.0.25420.1 Copyright (c) Microsoft Corporation. All rights reserved. Starting test execution, please wait...

挂起 5 分钟,然后

Error: An exception occurred while invoking executor 'executor://mstestadapter/v2': Object '/5243803c_c5e9_4f2c_bd7d_05acf3030dfa/veajeovlsl8zvqsxjaq47f1d_25.rem' has been disconnected or does not exist at the server.

这总是在构建服务器上重现,我设法用调试器重现了一次并获得了以下堆栈跟踪:

System.Runtime.Remoting.RemotingException: 'Object '/5594bcf8_9093_482c_aa7b_bb6b6f25dd27/gudsmiyjksi5no4zhgahfzqu_9.rem' has been disconnected or does not exist at the server.'

>   Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTestsWithTestRunner(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestExecutionRecorder testExecutionRecorder, string source, Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner testRunner)    Unknown
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTestsInSource(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestExecutionRecorder testExecutionRecorder, string source, bool isDeploymentDone)   Unknown
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle, bool isDeploymentDone)  Unknown
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.RunTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle, Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.TestRunCancellationToken runCancellationToken)   Unknown
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor.RunTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle) Unknown
    Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTestInternalWithExecutors(System.Collections.Generic.IEnumerable<System.Uri> executorUris, bool hasTests, System.Collections.Generic.Dictionary<System.Uri, System.Collections.Generic.IEnumerable<string>> executorUriVsSourceList, System.Collections.Generic.Dictionary<System.Uri, System.Collections.Generic.List<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>> executorUriVsTestList, Microsoft.VisualStudio.TestPlatform.Core.RunContext runContext, long totalTests, Microsoft.VisualStudio.TestPlatform.Common.Utilities.MeasurementBlockWrapper mb)    Unknown
    Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTestsInternal(System.Collections.Generic.IEnumerable<object> testOrSources, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunSettings runSettings, Microsoft.VisualStudio.TestPlatform.Core.TestExecutionContext executionContext) Unknown
    Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTests(System.Collections.Generic.IEnumerable<object> testsOrSources, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunSettings runSettings, Microsoft.VisualStudio.TestPlatform.Core.TestExecutionContext executionContext)    Unknown
    Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTests(object data)    Unknown
    mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
    mscorlib.dll!System.Threading.ThreadHelper.ThreadStart(object obj)  Unknown

我尝试同时使用 Visual Studio 20152017,得到了相同的结果。

我的解决方案是使用包 MSTest.TestAdapterMSTest.TestFramework 两个版本 1.1.11

根据这个帖子: ,

我尝试升级 MSTest 软件包版本,但无法在本地 运行 使用更高版本。

此外,我之前使用 1.1.11 包成功地 运行 对其他项目进行了单元测试。

是的,这是旧版本上的 MSTest 问题。

因此,解决方案是在构建代理计算机上将 MSTest 升级到 1.1.13 或更高版本。