'Cannot Run or Debug C# tests with CodeLens in VSCode
I am trying to run my xUnit tests within VSCode using the Run CodeLens
.
I am using VSCode 1.65.0 with .Net 6 (6.0.200) on a 2019 MacBook Pro (Intel) with the v1.24.1 of the C# VSCode extension.
I have run it using the dotnet test command, the .NET Core Test Explore Plugin and VS2022, and these work as expected.
This is the output log I get
----- 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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
