linuxvisual-studiocmakecpprest-sdk

CMake Project not loading on WSL2 via Visual Studio 2022


I am using Visual Studio 2022 preview.

I am trying to Compile and Run Cpprest based Project on WSL2 Debian Distribution. I have CMake v3.21.2 in Debian installed.

the project builds and runs on bare linux system as there is already Dockerfile present in project directory and tested by me.

while opening project in Visual Studio i get following Error in Cross Platform Logging window and i am not able to build and run the project.

it says file .vs/SecureChatServer/out/build/linux-default/.cmake/api/v1/query/client-MicrosoftVS/query.json in WSL2 Distribution does not exist

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.

Solution

  • The Solution to problem is manually creating the query.json file at location

    $HOME/.vs/$PROJECT_NAME/out/build/linux-default/.cmake/api/v1/query/client-MicrosoftVS/query.json

    the content of the query.json should be

    {
       "requests":[
          {
             "kind":"cache",
             "version":2
          },
          {
             "kind":"cmakeFiles",
             "version":1
          },
          {
             "kind":"codemodel",
             "version":2
          }
       ]
    }