[英]Cannot run .NET Core 3.1 tests projects on Visual Studio 2019 for Mac
I am having trouble running tests from inside VS.我在 VS 内部运行测试时遇到问题。 I created the simplest solution with just one NUnit Test project from the template and one test with Assert.IsTrue(true).
我使用模板中的一个 NUnit 测试项目和一个使用 Assert.IsTrue(true) 的测试创建了最简单的解决方案。
Here are the NuGet packages I added to the project with their versions in case it helps:以下是我添加到项目中的 NuGet 包及其版本,以防万一:
Here is the output I get when running the tests from the command line using dotnet test [projName]:这是使用 dotnet test [projName] 从命令行运行测试时得到的输出:
Determining projects to restore...
Restored /Users/OpenMinder/DevTraining/Test/Test.csproj (in 331 ms).
Test -> /Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.dll
Test run for /Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.dll (.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.8.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 29 ms - /Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.dll (netcoreapp3.1)
But whenever I try to run them from VS for mac I get the following behaviour:但是每当我尝试从 VS for mac 运行它们时,我都会得到以下行为:
The tests names don't show up in the panel测试名称未显示在面板中
The test run doesn't finish测试运行未完成
I get the following error in the output:我在输出中收到以下错误:
Failed to launch testhost with error: System.AggregateException: One or more errors occurred. (ApplicationName='/usr/local/bin/dotnet', CommandLine='exec --runtimeconfig "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.runtimeconfig.json" --depsfile "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.deps.json" "/Users/OpenMinder/.nuget/packages/microsoft.testplatform.testhost/16.8.0/lib/netcoreapp2.1/testhost.dll" --port 56039 --endpoint 127.0.0.1:056039 --role client --parentprocessid 8638 --telemetryoptedin false', CurrentDirectory='/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1', Native error= Cannot find the specified file) ---> System.ComponentModel.Win32Exception: ApplicationName='/usr/local/bin/dotnet', CommandLine='exec --runtimeconfig "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.runtimeconfig.json" --depsfile "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.deps.json" "/Users/OpenMinder/.nuget/packages/microsoft.testplatform.testhost/16.8.0/lib/netcoreapp2.1/testhost.dll" --port 56039 --endpoint 127.0.0.1:056039 --role client --parentprocessid 8638 --telemetryoptedin false', CurrentDirectory='/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1', Native error= Cannot find the specified file
at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0029f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System/System.Diagnostics/Process.cs:778
at System.Diagnostics.Process.Start () [0x0003a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs:2006
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.ProcessHelper.LaunchProcess (System.String processPath, System.String arguments, System.String workingDirectory, System.Collections.Generic.IDictionary`2[TKey,TValue] envVariables, System.Action`2[T1,T2] errorCallback, System.Action`1[T] exitCallBack) [0x00101] in <06d9ef76610d4473ae17230fef5fa07d>:0
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchHost (Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testHostStartInfo, System.Threading.CancellationToken cancellationToken) [0x0006d] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager+<>c__DisplayClass34_0.<LaunchTestHostAsync>b__0 () [0x00000] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:534
at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchTestHostAsync (Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testHostStartInfo, System.Threading.CancellationToken cancellationToken) [0x00096] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00013] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2029
at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:496
at System.Threading.Tasks.Task`1[TResult].get_Result () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:466
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel (System.Collections.Generic.IEnumerable`1[T] sources) [0x00115] in <c4016cc04b6c4d6fb0610501f99366ce>:0
---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): ApplicationName='/usr/local/bin/dotnet', CommandLine='exec --runtimeconfig "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.runtimeconfig.json" --depsfile "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.deps.json" "/Users/OpenMinder/.nuget/packages/microsoft.testplatform.testhost/16.8.0/lib/netcoreapp2.1/testhost.dll" --port 56039 --endpoint 127.0.0.1:056039 --role client --parentprocessid 8638 --telemetryoptedin false', CurrentDirectory='/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1', Native error= Cannot find the specified file
at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0029f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System/System.Diagnostics/Process.cs:778
at System.Diagnostics.Process.Start () [0x0003a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs:2006
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.ProcessHelper.LaunchProcess (System.String processPath, System.String arguments, System.String workingDirectory, System.Collections.Generic.IDictionary`2[TKey,TValue] envVariables, System.Action`2[T1,T2] errorCallback, System.Action`1[T] exitCallBack) [0x00101] in <06d9ef76610d4473ae17230fef5fa07d>:0
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchHost (Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testHostStartInfo, System.Threading.CancellationToken cancellationToken) [0x0006d] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager+<>c__DisplayClass34_0.<LaunchTestHostAsync>b__0 () [0x00000] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:534
at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchTestHostAsync (Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testHostStartInfo, System.Threading.CancellationToken cancellationToken) [0x00096] in <8b213d9f519447a3ad29e7a4013d8bc9>:0 <---
Failed to launch testhost with error: System.AggregateException: One or more errors occurred. (ApplicationName='/usr/local/bin/dotnet', CommandLine='exec --runtimeconfig "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.runtimeconfig.json" --depsfile "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.deps.json" "/Users/OpenMinder/.nuget/packages/microsoft.testplatform.testhost/16.8.0/lib/netcoreapp2.1/testhost.dll" --port 56039 --endpoint 127.0.0.1:056039 --role client --parentprocessid 8638 --telemetryoptedin false', CurrentDirectory='/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1', Native error= Cannot find the specified file) ---> System.ComponentModel.Win32Exception: ApplicationName='/usr/local/bin/dotnet', CommandLine='exec --runtimeconfig "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.runtimeconfig.json" --depsfile "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.deps.json" "/Users/OpenMinder/.nuget/packages/microsoft.testplatform.testhost/16.8.0/lib/netcoreapp2.1/testhost.dll" --port 56039 --endpoint 127.0.0.1:056039 --role client --parentprocessid 8638 --telemetryoptedin false', CurrentDirectory='/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1', Native error= Cannot find the specified file
at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0029f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System/System.Diagnostics/Process.cs:778
at System.Diagnostics.Process.Start () [0x0003a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs:2006
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.ProcessHelper.LaunchProcess (System.String processPath, System.String arguments, System.String workingDirectory, System.Collections.Generic.IDictionary`2[TKey,TValue] envVariables, System.Action`2[T1,T2] errorCallback, System.Action`1[T] exitCallBack) [0x00101] in <06d9ef76610d4473ae17230fef5fa07d>:0
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchHost (Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testHostStartInfo, System.Threading.CancellationToken cancellationToken) [0x0006d] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager+<>c__DisplayClass34_0.<LaunchTestHostAsync>b__0 () [0x00000] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:534
at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchTestHostAsync (Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testHostStartInfo, System.Threading.CancellationToken cancellationToken) [0x00096] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00013] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2029
at System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:496
at System.Threading.Tasks.Task`1[TResult].get_Result () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:466
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel (System.Collections.Generic.IEnumerable`1[T] sources) [0x00115] in <c4016cc04b6c4d6fb0610501f99366ce>:0
---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): ApplicationName='/usr/local/bin/dotnet', CommandLine='exec --runtimeconfig "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.runtimeconfig.json" --depsfile "/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1/Test.deps.json" "/Users/OpenMinder/.nuget/packages/microsoft.testplatform.testhost/16.8.0/lib/netcoreapp2.1/testhost.dll" --port 56039 --endpoint 127.0.0.1:056039 --role client --parentprocessid 8638 --telemetryoptedin false', CurrentDirectory='/Users/OpenMinder/DevTraining/Test/bin/Debug/netcoreapp3.1', Native error= Cannot find the specified file
at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0029f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System/System.Diagnostics/Process.cs:778
at System.Diagnostics.Process.Start () [0x0003a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs:2006
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.ProcessHelper.LaunchProcess (System.String processPath, System.String arguments, System.String workingDirectory, System.Collections.Generic.IDictionary`2[TKey,TValue] envVariables, System.Action`2[T1,T2] errorCallback, System.Action`1[T] exitCallBack) [0x00101] in <06d9ef76610d4473ae17230fef5fa07d>:0
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchHost (Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testHostStartInfo, System.Threading.CancellationToken cancellationToken) [0x0006d] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager+<>c__DisplayClass34_0.<LaunchTestHostAsync>b__0 () [0x00000] in <8b213d9f519447a3ad29e7a4013d8bc9>:0
at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:534
at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchTestHostAsync (Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testHostStartInfo, System.Threading.CancellationToken cancellationToken) [0x00096] in <8b213d9f519447a3ad29e7a4013d8bc9>:0 <---
VS version 8.8 build 2913 VS 8.8 版本 2913
macOS Catalina 10.15.7 macOS Catalina 10.15.7
My current dotnet info:我当前的 dotnet 信息:
.NET SDK (reflecting any global.json):
Version: 5.0.100
Commit: 5044b93829
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/5.0.100/
Host (useful for support):
Version: 5.0.0
Commit: cf258a14b7
.NET SDKs installed:
3.1.404 [/usr/local/share/dotnet/sdk]
5.0.100 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Anybody has any idea of what else I can try?有人知道我还能尝试什么吗?
Let me know if you need any more information.如果您需要更多信息,请告诉我。
Maybe this helps someone, I managed to solve this now, I created a symbolic link in the past to fix something else and I forgot about that.也许这对某人有帮助,我现在设法解决了这个问题,我过去创建了一个符号链接来解决其他问题,但我忘记了。
I fixed this by removing that link with this command:我通过使用以下命令删除该链接来解决此问题:
rm /usr/local/bin/dotnet
Now I am able to use both VS Code and VS for Mac.现在我可以同时使用 VS Code 和 VS for Mac。
Thanks!谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.