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

Time:03-13

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.

CodePudding user response:

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

  • Related