Visual Studio 2019 allows C++ developers to target both Windows and Linux (including the Windows Subsystem for Linux) from the comfort of a single IDE. Visual Studio 2019 version 16.7 Preview 3 introduces two features specific to Linux development: improved build incrementality for MSBuild-based Linux projects, and support for a wider range of Linux distributions and shells.

There are two ways C++ developers can target Linux systems from Visual Studio. Our recommendation for anything cross-platform or with an eye to open-sourcing is our native support for CMake. This allows you to leverage the same source code and build scripts to target multiple platforms. Alternatively, you can create a MSBuild-based Linux project for a familiar Visual Studio experience.

Improved build incrementality for MSBuild-based Linux projects

You can now leverage Ninja for faster incremental builds in MSBuild-based Linux projects. To enable building with Ninja, navigate to Property Pages > General and set “Enable Incremental Build” to “With Ninja”.

Image of Property Pages with the new property "Enable Incremental Build" highlighted and set to "With Ninja"

Make sure you have ninja installed on your Linux system. You can install ninja on Debian-based Linux systems with the following commands:

sudo apt-get update

sudo apt-get install ninja-build

We tested Ninja’s build performance with a MSBuild-based Linux project that contained 1000 .h files and 1000 .cpp files. Ninja led to faster build times for both a full rebuild and a build where one header file was changed.

End to end build time for full rebuild (in min)End to end build time with one change (in min)Enable Incremental Build == With Ninja8:010:32Enable Incremental Build == No12:575:26

These tests were run against a local VM (Ubuntu 20.04) connected to Visual Studio over SSH, but you can leverage these improvements with both our SSH support and native support for WSL. As a reminder, in MSBuild-based Linux projects you can select your platform toolset (WSL or remote) via Property Pages > General > Platform Toolset.

#c++ #linux #visual studio #programming-c #cplusplus

C++ Linux development with Visual Studio
16.20 GEEK