Compile_commands.json from non Cmake msvc project

Is there a way to get msvc to generate a compile_commands.json file when it’s using its llvm compiler? (a normal msvc project with .sln, no cmake stuff is used)

edit, found this Clang Power Tools 2022 - Visual Studio Marketplace which seems to have a way to export compile commands json but you have to manually do it.

still wonder if there’s a way to generate it on compile.

You can add it as a Makefile target and then have that target run with every build. Using the compiledb tool is fast and doesn’t require a clean re-build. Here’s how I do it (the second version is better):