Operating system: Windows 11 Pro 10.0.22631 build 22631 (built remotely on Ubuntu 20.04.6 LTS)
Visual Studio version: VS2022 Pro 17.10.3 (not vs code)
SonarLint plugin version: 8.5.0.10497
Programming language you’re coding in: C++ (CMake Project)
Is connected mode used: no
And a thorough description of the problem / question:
We are developing on a windows machine and building remotely to an Ubuntu linux box. I’ve followed the instructions provided to setup SonarLint without connected mode, most importantly including the cmakelists.txt addition of set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
however, the compile_commands.json lives on the remote linux system in $HOME/.vs/${projectDirName}/out/build
Are there furthar integration steps I missed or is there a workaround I can utilize?
Edit: I’ve found something interesting but still doesn’t help in my specific case. I’ve run the msvc_x64_x64 inheritEnvironment and it would generate me the appropriate compile_commands.json file in my out/build with the above configuration, however it’s only not generating these when I switch to x64_linux. It still generates it remotely on the linux box, but nothing gets carried back over to the local windows development machine. Is there a way to copy it over or tell the environment to build the compile_commands.json locally?
[SLCoreAnalyzer] Analyzing C:\Workspace\project\app\appversion\source\file.cpp with id
[CMake] Could not locate compilation database at 'C:\Workspace\project\app\out\build\compile_commands.json'. Make sure that your project is configured correctly.
See https://docs.sonarsource.com/sonarlint/visual-studio/getting-started/requirements/#language-specific-requirements for more information..
Unable to retrieve the configuration for file 'C:\Workspace\project\app\appversion\source\file.cpp'.
I’ve redacted the specific project names and file names, but the structure is still the same. In my edit I made note that compiling locally using the cmakesettings inheritEnvironment of msvc_x64_x64 produces the compile_commands.json locally on my dev machine, but when using a remote build with linux_x64 inheritEnvironment options, the compile_commands.json is generated remotely on the linux box, I have confirmed the file exists in the remote $HOME/.vs/${projectDirName}/out/build I’ve double checked that my build root is set properly and points to the correct location. would I need to copy the remote build root to the normal build root of the remote system to point remotely to the compile_commands.json or is there a way to move it to the local machine?
In short, while there is support for CMake, the remote build scenario is not yet supported.
Simply copying the compile_commands.json file may not yield the desired results, as this file contains absolute paths to the source files as well as the compiler, system headers, etc… which differ between Windows and Linux environments. To generate the compile_commands.json file, you don’t necessarily need to build the entire project—this can be done independently. One possible workaround might involve manually running CMake to generate the compile_commands.json file on your local machine, though please note that this approach has not been extensively tested and could depend on your specific project configuration.
On a positive note, there will be active development within SonarLint for Visual Studio to enhance C++ analysis capabilities (currently scheduled for 2 weeks starting November 19). These improvements will allow the analysis team to work on features like the remote build functionality that you originally requested.
In the meantime, could you provide a bit more detail about your setup? Specifically, is your remote machine a WSL instance, or another Linux machine on your network?
Our remote machine is a physical PC on our network running ubuntu 20.04 (x64). We use Visual studio 2022 remote build capabilities to target the remote machine as the build environment. This all happens through the Cross Platform Manager that handles our SSH connection to said remote machine. Here is an example of our build configuration when connected to a remote machine.