linux - CMake 项目未通过 Visual Studio 2022 在 WSL2 上加载
问题描述
我正在使用 Visual Studio 2022 预览版。
我正在尝试在 WSL2 Debian 发行版上编译和运行基于Cpprest的项目。我在 Debian 中安装了 CMake v3.21.2。
该项目在裸 linux 系统上构建和运行,因为项目目录中已经Dockerfile
存在并由我测试。
在 Visual Studio 中打开项目时,我在Cross Platform Logging
窗口中收到以下错误,我无法构建和运行项目。
它说.vs/SecureChatServer/out/build/linux-default/.cmake/api/v1/query/client-MicrosoftVS/query.json
WSL2 Distribution 中的文件不存在
15:17:34.6074634 [Info, Thread 86] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache: ClearSingleConfigurationAsync: Clearing cache entry for CMakeLists.txt.
15:17:34.6530612 [Info, Thread 93] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Starting scan ...
15:17:34.7459086 [Info, Thread 93] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Scanner Parsing starting: projectfilepath CMakeLists.txt FileScanType: System.Collections.Generic.IReadOnlyDictionary`2[System.Type,System.Object] Config Name:linux-default
15:17:34.8382805 [Info, Thread 84] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache: CacheGenerationStarted root: CMAKELISTS.TXTlinux-default CMakeLists.txt linux-default
15:17:34.8472770 [Info, Thread 84] Microsoft.VisualStudio.CMake.Linux.Project.RemoteCMakeParser: RemoteCMakeParser ctor
15:17:34.8472770 [Info, Thread 84] libcmake.Linux.RemoteCMakeParser: RemoteCMakeParser ctor
15:17:34.8472770 [Info, Thread 84] Microsoft.VisualStudio.CMake.Linux.Project.RemoteCMakeParser: RemoteCMakeParser finished
15:17:34.8482814 [Info, Thread 84] libcmake.Linux.RemoteCMakeUtils: RemoteCMakeCopyFilesStarted Copying source directory 'C:\Users\Tushar\Downloads\Semester 7\MP\SecureChatServer\' to destination directory '/home/tushar/.vs/SecureChatServer' on '' (method=rsync).
15:17:35.1282745 [Info, Thread 11] libcmake.Linux.IO.DirectoryScan: Scan time: 79
15:17:35.1552754 [Info, Thread 11] libcmake.Linux.IO.DirectoryScan: Compare time: 26
15:17:35.1992766 [Info, Thread 11] libcmake.Linux.RemoteCMakeUtils: RemoteCMakeCopyFilesFinished Finished copying files (elapsed time 00h:00m:00s:200ms).
15:17:35.3902747 [Info, Thread 52] libcmake.Linux.RemoteCMakeParser: ParseAsync
15:17:35.3912810 [Info, Thread 52] libcmake.Linux.RemoteCMakeParser: CreateCMakeDaemonAsync
15:17:35.3912810 [Info, Thread 52] libcmake.Linux.RemoteCMakeParameters: Connecting to the remote system
15:17:35.5384620 [Info, Thread 52] libcmake.Linux.RemoteCMakeParameters: Connected to the remote system
15:17:35.6864045 [Info, Thread 14] libcmake.CMakeDaemonDriver: CMake version parsed: True, input string: cmake version 3.21.2, matched version: 3.21.2.0
15:17:35.6883976 [Info, Thread 14] libcmake.Linux.RemoteCMakeParameters: CMake version '3.21.2.0' identified on the remote
15:17:35.8373996 [Info, Thread 9] libcmake.Linux.RemoteCMakeParameters: Found cmake executable at /usr/local/bin/cmake.
15:17:36.0284001 [Info, Thread 14] libcmake.CMakeDaemonDriver: CMake version parsed: True, input string: cmake version 3.21.2, matched version: 3.21.2.0
15:17:36.0304011 [Info, Thread 14] libcmake.Linux.RemoteCMakeParser: CreateCMakeDaemonAsync done
15:17:36.0304011 [Info, Thread 14] libcmake.CMakeListsParser: Parsing without cache
15:17:36.1454044 [Info, Thread 14] libcmake.CMakeDaemonDriver: CMake version parsed: True, input string: cmake version 3.21.2, matched version: 3.21.2.0
15:17:36.1484013 [Info, Thread 14] libcmake.Linux.RemoteFileApiDaemon: CMake version '3.21.2.0' identified on the remote
15:17:36.1854036 [Error, Thread 14] Microsoft.VisualStudio.CMake.Project.ExternalBuildProject.ProjectProvider: liblinux.IO.IOException: Failed to get permissions for file '/home/tushar/.vs/SecureChatServer/out/build/linux-default/.cmake/api/v1/query/client-MicrosoftVS/query.json'. ---> liblinux.IO.IOException: Failed to get permissions for file '/home/tushar/.vs/SecureChatServer/out/build/linux-default/.cmake/api/v1/query/client-MicrosoftVS/query.json'.
at liblinux.Local.IO.WindowsSubsystemFileSystem.StatPath(String remotePath, String format, String error)
at liblinux.Local.IO.WindowsSubsystemFileSystem.GetPermissions(String remotePath)
at liblinux.IO.RemoteFileSystemInfo..ctor(IRemoteFileSystem fs, String remotePath)
at liblinux.Local.IO.WindowsSubsystemFileSystem.UploadFile(String localFileName, String remoteFileName)
--- End of inner exception stack trace ---
at liblinux.Local.IO.WindowsSubsystemFileSystem.UploadFile(String localFileName, String remoteFileName)
at liblinux.Local.IO.WindowsSubsystemFileSystem.UploadFileAsync(String localFileName, String remoteFileName, Int32 bufferSize, CancellationToken cancellationToken)
at libcmake.Linux.RemoteFileApiDaemon.<WriteQueryFileAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at libcmake.Linux.RemoteFileApiDaemon.<GenerateCacheAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at libcmake.CMakeListsParser.<ParseImplAsync>d__39.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at libcmake.Linux.RemoteCMakeParser.<ParseAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.CMake.Linux.Project.RemoteCMakeParser.<ParseAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.CMake.Project.ExternalBuildProject.ProjectProvider.<ParseProjectAsync>d__33.MoveNext()
15:17:36.1854036 [Error, Thread 14] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache: Unknown exception during cache generation: root: CMAKELISTS.TXTlinux-default CMakeLists.txt linux-default
15:17:36.1864019 [Error, Thread 36] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache: liblinux.IO.IOException: Failed to get permissions for file '/home/tushar/.vs/SecureChatServer/out/build/linux-default/.cmake/api/v1/query/client-MicrosoftVS/query.json'. ---> liblinux.IO.IOException: Failed to get permissions for file '/home/tushar/.vs/SecureChatServer/out/build/linux-default/.cmake/api/v1/query/client-MicrosoftVS/query.json'.
at liblinux.Local.IO.WindowsSubsystemFileSystem.StatPath(String remotePath, String format, String error)
at liblinux.Local.IO.WindowsSubsystemFileSystem.GetPermissions(String remotePath)
at liblinux.IO.RemoteFileSystemInfo..ctor(IRemoteFileSystem fs, String remotePath)
at liblinux.Local.IO.WindowsSubsystemFileSystem.UploadFile(String localFileName, String remoteFileName)
--- End of inner exception stack trace ---
at liblinux.Local.IO.WindowsSubsystemFileSystem.UploadFile(String localFileName, String remoteFileName)
at liblinux.Local.IO.WindowsSubsystemFileSystem.UploadFileAsync(String localFileName, String remoteFileName, Int32 bufferSize, CancellationToken cancellationToken)
at libcmake.Linux.RemoteFileApiDaemon.<WriteQueryFileAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at libcmake.Linux.RemoteFileApiDaemon.<GenerateCacheAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at libcmake.CMakeListsParser.<ParseImplAsync>d__39.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at libcmake.Linux.RemoteCMakeParser.<ParseAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.CMake.Linux.Project.RemoteCMakeParser.<ParseAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.CMake.Project.ExternalBuildProject.ProjectProvider.<ParseProjectAsync>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.CMake.Project.ExternalBuildProject.ProjectProvider.<ParseProjectAsync>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.ParseCache.<ParseAsyncImpl>d__34.MoveNext()
15:17:36.1904000 [Info, Thread 46] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Scanner Parsing done: projectfilepath CMakeLists.txt FileScanType: System.Collections.Generic.IReadOnlyDictionary`2[System.Type,System.Object] Config Name:linux-default
15:17:36.1924027 [Info, Thread 53] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Compute file data values for CMakeLists.txt Config linux-default
15:17:36.1943992 [Error, Thread 113] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: FDV Error for CMakeLists.txt Config linux-default Canceled False AutoGenerateCanceled False
15:17:36.2074002 [Info, Thread 107] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: OnFileScannerCompleted for CMakeLists.txt
15:17:36.2084013 [Info, Thread 107] Microsoft.VisualStudio.Workspace.ExternalBuildFramework.Impl.Services.BuildProjectScannerService: Finishing scan.
解决方案
问题的解决方案是query.json
在位置手动创建文件
$HOME/.vs/$PROJECT_NAME/out/build/linux-default/.cmake/api/v1/query/client-MicrosoftVS/query.json
query.json 的内容应该是
{
"requests":[
{
"kind":"cache",
"version":2
},
{
"kind":"cmakeFiles",
"version":1
},
{
"kind":"codemodel",
"version":2
}
]
}
推荐阅读
- google-apps-script - How to unzip .ZIP mime type (application / x-zip-compressed) in google app script
- elasticsearch - 在elasticsearch中搜索文档内的匹配对象
- java-bytecode-asm - How do I get the parameter instructions that belong to a method?
- c# - 在 WPF UserControl 中添加幻灯片动画
- python - run "%run" command from string
- reactjs - Audio element and react-player not working on iPhone mobile
- google-bigquery - Spotfire 和 BigQuery
- mediawiki - Visual Editor is giving me 500 Errors
- c++ - 尝试轮询事件时出现 SDL2 分段错误
- c# - User Defined Table Type Datetime conversion error