Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while running test with vscode: some sort of issue with the project file

This issue occurs on MacOS using VSCode to debug an individual test (instead of the entire suite). When I try to debug this test with vscode, I get the following output:

/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error MSB3883: Unexpected exception:  [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error : DirectoryNotFoundException: Could not find a part of the path '/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/bin/Debug/net6.0/ref/Reusable.dll'. [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at Interop.CheckIo(Error error, String path, Boolean isDirectory, Func`2 errorRewriter) [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/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/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at Microsoft.CodeAnalysis.BuildTasks.CopyRefAssembly.Copy() [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]
/usr/local/share/dotnet/sdk/6.0.201/Microsoft.Common.CurrentVersion.targets(4650,5): error :  [/Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/Reusable.csproj]

The issue here is, of course, that /Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/bin/Debug/net6.0/ref doesn't exist, but it's not generated by the build system! Why does it think that the .dll is in ref and not under the folder directly above it?

This only happens when I try to debug the test in VS. It looks like it's an issue with the project... Does anyone know what could be wrong? If you need more information let me know. I can include the project files if necessary.

like image 538
BeenEncoded Avatar asked Nov 03 '25 12:11

BeenEncoded


1 Answers

I've run into this as well. Found a workaround by adding this to my project file:

<PropertyGroup>
  <ProduceReferenceAssemblyInOutDir>true</ProduceReferenceAssemblyInOutDir>
</PropertyGroup>

Discovered this workaround here https://github.com/microsoft/vscode-azurefunctions/issues/3051

This is due to a breaking change introduced in the .NET 6 SDK. See: https://learn.microsoft.com/dotnet/core/compatibility/sdk/6.0/write-reference-assemblies-to-obj

like image 157
Alan West Avatar answered Nov 05 '25 02:11

Alan West



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!