我正在嘗試使用 Run CodeLens 在 VSCode 中運行我的 xUnit 測驗
。
我在帶有 C# VSCode 擴展的 v1.24.1 的 2019 MacBook Pro (Intel) 上使用 VSCode 1.65.0 和 .Net 6 (6.0.200)。
我已經使用dotnet test命令、.NET Core Test Explore Plugin 和 VS2022 運行它,并且這些都按預期作業。
這是我得到的輸出日志
----- Running test method "net6TestTest.TestControllerTest.Get_ShouldReturn_String" -----
Microsoft (R) Build Engine version 17.1.0 ae57d105c for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error MSB3883: Unexpected exception: [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : DirectoryNotFoundException: Could not find a part of the path '/Users/ssmale/Projects/net6Test/net6Test/bin/Debug/net6.0/ref/net6Test.dll'. [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.CodeAnalysis.BuildTasks.CopyRefAssembly.Copy() [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
Build FAILED.
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error MSB3883: Unexpected exception: [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : DirectoryNotFoundException: Could not find a part of the path '/Users/ssmale/Projects/net6Test/net6Test/bin/Debug/net6.0/ref/net6Test.dll'. [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.CodeAnalysis.BuildTasks.CopyRefAssembly.Copy() [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : [/Users/ssmale/Projects/net6Test/net6Test/net6Test.csproj]
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:01.26
uj5u.com熱心網友回復:
要使用 .net 6,您需要更新 Omnisharp 設定以使用“現代”方式
您需要切換的設定是omnisharp.useModernNet。它在 C# 擴展的讀取中進行了描述。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/439541.html
