运行 使用 vscode 测试时出错:项目文件存在某种问题
Error while running test with vscode: some sort of issue with the project file
此问题发生在使用 VSCode 调试单个测试(而不是整个套件)的 MacOS 上。
当我尝试使用 vscode 调试此测试时,我得到以下输出:
/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]
这里的问题当然是 /Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/bin/Debug/net6.0/ref
不存在,但它不是由构建系统生成的!为什么它认为.dll 在 ref 中而不是在其正上方的文件夹下?
只有当我尝试在 VS 中调试测试时才会发生这种情况。看起来这是项目的问题......有谁知道可能出了什么问题?如果您需要更多信息,请告诉我。如有必要,我可以包含项目文件。
我也 运行 喜欢这个。通过将此添加到我的项目文件找到了解决方法:
<PropertyGroup>
<ProduceReferenceAssemblyInOutDir>true</ProduceReferenceAssemblyInOutDir>
</PropertyGroup>
在此处发现此解决方法 https://github.com/microsoft/vscode-azurefunctions/issues/3051
此问题发生在使用 VSCode 调试单个测试(而不是整个套件)的 MacOS 上。 当我尝试使用 vscode 调试此测试时,我得到以下输出:
/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]
这里的问题当然是 /Users/username/Documents/coding/CSharp/current_projects/Project-Name/Reusable/bin/Debug/net6.0/ref
不存在,但它不是由构建系统生成的!为什么它认为.dll 在 ref 中而不是在其正上方的文件夹下?
只有当我尝试在 VS 中调试测试时才会发生这种情况。看起来这是项目的问题......有谁知道可能出了什么问题?如果您需要更多信息,请告诉我。如有必要,我可以包含项目文件。
我也 运行 喜欢这个。通过将此添加到我的项目文件找到了解决方法:
<PropertyGroup>
<ProduceReferenceAssemblyInOutDir>true</ProduceReferenceAssemblyInOutDir>
</PropertyGroup>
在此处发现此解决方法 https://github.com/microsoft/vscode-azurefunctions/issues/3051