Visual Studio 测试发现期间出现 dotnet 核心套接字错误

Visual Studio dotnet core socket error during test discovery

我正在 Visual Studio 创建一个测试项目。它构建,但未能发现项目中的测试并出现以下错误:

Unable to start C:\Program Files\dotnet\dotnet.exe
dotnet-test Error: 0 : [ReportingChannel]: Waiting for message failed System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine

错误日志的全文可以在这里看到at this Github issue

这是我的 project.json 文件

"version": "1.0.0-*",

"dependencies": {
    "MyProject.Web": {
        "target": "project",
        "version": "1.0.0-*"
    },
    "Moq": "4.6.38-alpha",
    "xunit": "2.2.0-beta3-build3402",
            "xunit.runner.console": "2.2.0-beta3-build3402",
    "xunit.runner.visualstudio": "2.2.0-beta3-build1187"
},

"testRunner": "xunit",

"frameworks": {
    "netcoreapp1.0": {
        "imports": "dnxcore50",
        "dependencies": {
            "Microsoft.NETCore.App": {
                "type": "platform",
                "version": "1.0.0"
            }
        }
    }
},
"runtimes": {
    "win10-x64": {}
}

令人沮丧的是,直到昨天,这个项目已经在几周内正常运行了 40 次左右的测试。有什么想法可以解决这个问题吗?

嗯,我安装了 dotnet-test-xunit 包,现在 VS 测试资源管理器可以看到并运行我的测试。 Resharper 仍然找不到它们,但我想在整个 MSBuild dotnet 核心问题得到解决之前,我们会再经历几次。

我在升级包 (nuget) 后遇到了类似的问题,然后通过这个线程解决了它(如果你的目标是核心和 netxxx,顺序很重要)https://github.com/xunit/xunit/issues/900