If you try to include files ftom \\wsl$\anywhere you are probably misunderstanding how Visual Studio's “Linux Development with C++” feature works.
The official documentation makes it clear that it doesn't actually use the Visual Studio compiler, but rather gcc on a “remote” Linux system via CMake: you can use WSL as the target, but
- you need gcc, ninja, gdb, possibly CMake installed in your WSL Ubuntu, which you could use directly instead
- you must not access files from WSL directly to avoid corruption
- you probably want a Windows build of your project anyway
- OpenGL in a headless WSL environment isn't going to work well (or at all)
So, is using a remote debugger (Visual Studio → WSL) worth the setup effort and the flakiness compared to using CMake, Meson or other portable build systems directly? Don't you want a Windows version of your project, which you could develop in Visual Studio's “comfort zone” without troublesome perversions and with reasonable assurance of being able to compile a Linux version when the need arises?