IntelliSense for Remote Linux Headers
In Visual Studio 2017 15.7 Preview 3 we are introducing IntelliSense for headers on remote Linux connections. This is part of the Linux development with C++ workload that you can choose in the Visual Studio installer. If you are just getting started with the C++ Linux support in Visual Studio you can read our C++ Linux tutorial at aka.ms/vslinux.
When you add a new connection in the Connection Manager we will automatically determine the include directories for the compiler on the system. Those directories will be zipped up and copied to a directory on your local Windows machine. Then, when you use that connection in a Visual Studio or CMake project, the headers in those directories will be used to provide IntelliSense.
Note that you do need zip installed on the Linux machine you are connecting to for this to work. Using apt-get that can be done via:
apt install zip
To add a new connection, go to Tools > Options, Select Cross Platform > Connection Manager and select Add. The Connect to Remote System Dialog will appear.
This dialog also appears if you try to perform an operation in a project that requires a remote Linux connection and you have none defined. Provide your connection information, host, user name, and credentials.
Upon establishing a successful connection, you will see a dialog that we have started gathering the headers for the connection.
Upon completion of creating the zip file you will see progress information on the status of copying and unzipping that to your local machine.
Now whenever you select this connection in a Linux project, whether it is a Visual Studio or CMake project, you will get IntelliSense from the headers of this connection. Here you can see that when peeking at the definition for endl the <ostream> header where that is defined is in my header cache, not a generic location.
To manage your header cache, navigate to Tools > Options, Select Cross Platform > Connection Manager > Remote Headers IntelliSense Manager. To update the header cache after making changes on your Linux machine, select your remote connection and select Update. If you want to keep a connection and free space by getting rid of the header cache, select the connection and choose Delete. If needed you can also disable automatically downloading headers for new connections here.
You can also see where we have saved the header files for the connection by selecting Explore which will open File Explorer in that location. This is not intended for you to make changes in this location, it should be treated as read only. Our Update mechanism will not respect changes made here manually.
If you have added connections in past releases they are not automatically opted into this experience. To add them go to Tools > Options, Select Cross Platform > Connection Manager > Remote Headers IntelliSense Manager. Select the connection that you want to get a local header cache for and select Download.
Download the Visual Studio 2017 Preview and select the Linux C++ Workload, add a Linux connection, and try it with your projects.
We will continue to improve this feature in subsequent releases. We already have plans to support project specific headers, including those added through CMake. We are also looking at ways to trigger the synchronization of headers automatically on use of a connection so manually updating won’t be required.
We love hearing about what is and isn’t working for you with new features like this and with the Linux workload in general. The best way to reach us is via our GitHub hosted issue list, directly via mail at email@example.com, or find me on Twitter @robotdad.