{"id":26246,"date":"2020-07-08T17:25:39","date_gmt":"2020-07-08T17:25:39","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=26246"},"modified":"2020-07-20T19:52:36","modified_gmt":"2020-07-20T19:52:36","slug":"c-linux-development-with-visual-studio-incremental-build-improvements-and-expanded-shell-support","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/c-linux-development-with-visual-studio-incremental-build-improvements-and-expanded-shell-support\/","title":{"rendered":"C++ Linux development with Visual Studio: incremental build improvements and expanded shell support"},"content":{"rendered":"<p>Visual Studio 2019 allows C++ developers to target both Windows and Linux (including the <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/c-with-visual-studio-2019-and-windows-subsystem-for-linux-wsl\/\">Windows Subsystem for Linux<\/a>) from the comfort of a single IDE. <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\">Visual Studio 2019 version 16.7 Preview 3<\/a> 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.<\/p>\n<p>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 <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/build\/cmake-projects-in-visual-studio?view=vs-2019\">native support for CMake<\/a>. This allows you to leverage the same source code and build scripts to target multiple platforms. Alternatively, you can create a <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/linux\/create-a-new-linux-project?view=vs-2019\">MSBuild-based Linux project<\/a> for a familiar Visual Studio experience.<\/p>\n<h4>Improved build incrementality for MSBuild-based Linux projects<\/h4>\n<p>You can now leverage <a href=\"https:\/\/ninja-build.org\/\">Ninja<\/a> for faster incremental builds in MSBuild-based Linux projects. To enable building with Ninja, navigate to Property Pages &gt; General and set \u201cEnable Incremental Build\u201d to \u201cWith Ninja\u201d.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-26247 size-large\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/07\/incrementalBuild-1024x668.png\" alt=\"Image of Property Pages with the new property &quot;Enable Incremental Build&quot; highlighted and set to &quot;With Ninja&quot;\" width=\"640\" height=\"418\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/07\/incrementalBuild-1024x668.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/07\/incrementalBuild-300x196.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/07\/incrementalBuild-768x501.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2020\/07\/incrementalBuild.png 1164w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>Make sure you have ninja installed on your Linux system. You can install ninja on Debian-based Linux systems with the following commands:<\/p>\n<pre>sudo apt-get update\r\n\r\nsudo apt-get install ninja-build<\/pre>\n<p>We tested Ninja\u2019s 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.<\/p>\n<table style=\"height: 84px; width: 99.1432%; border-collapse: collapse;\" border=\"1\">\n<tbody>\n<tr style=\"height: 28px;\">\n<td style=\"width: 467px; text-align: left; height: 28px;\"><\/td>\n<td style=\"width: 465px; text-align: left; height: 28px;\"><strong>End to end build time for full rebuild (in min)<\/strong><\/td>\n<td style=\"width: 466px; text-align: left; height: 28px;\"><strong>End to end build time with one change (in min)<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 467px; height: 28px;\"><strong>Enable Incremental Build == With Ninja<\/strong><\/td>\n<td style=\"width: 465px; height: 28px;\">8:01<\/td>\n<td style=\"width: 466px; height: 28px;\">0:32<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 467px; height: 28px;\"><strong>Enable Incremental Build == No<\/strong><\/td>\n<td style=\"width: 465px; height: 28px;\">12:57<\/td>\n<td style=\"width: 466px; height: 28px;\">5:26<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>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 &gt; General &gt; Platform Toolset.<\/p>\n<h4>Support for a wider range of Linux distributions and shells<\/h4>\n<p>We also added support for a wider range of Linux distributions and shells. These changes apply to both CMake projects and MSBuild-based Linux projects targeting a remote Linux system or WSL. Visual Studio now queries for the shell the first time a command is issued. It then decides how to format a command line when redirecting stderr and how to detach from a running command based on the shell that is discovered. Visual Studio now supports the following shells: <strong>sh, csh, bash, tcsh, ksh, zsh, and dash<\/strong>. If the shell found on the Linux system is not supported, then we fall back to explicitly use \u201csh\u201d for all commands.<\/p>\n<p>We also added new options and commands to <a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/linux\/connectionmanager-reference?view=vs-2019\">ConnectionManager.exe<\/a> to help you override the choice of shell for a connection. ConnectionManager.exe is a command-line utility to manage stored remote connections outside of Visual Studio.<\/p>\n<ul>\n<li><strong>ConnectionManager.exe list &#8211; -properties<\/strong>\n<ul>\n<li>When present, the list of properties defined for the connection will be printed out for each connection.<\/li>\n<\/ul>\n<\/li>\n<li><strong>ConnectionManager.exe modify [default | connection_id | user@host [- -port port]] &#8211; -property [key=value]<\/strong>\n<ul>\n<li>Define or modify a property on a connection. If \u201cvalue\u201d is empty, then the property \u201ckey\u201d is deleted. For example, use <strong>ConnectionManager.exe modify 21212121 &#8211; -property shell=csh<\/strong> to override the choice of shell for the connection with connection ID 21212121.<\/li>\n<li>You can run the command <strong>ConnectionManager.exe list<\/strong> to view a list of stored connections by connection ID.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Finally, we\u2019ve tested our support against a wider range of Linux distros through changes to the commands issued. \u00a0Key functionality like project creation, <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/improvements-to-accuracy-and-performance-of-linux-intellisense\/\">the remote header sync<\/a>, build, and debug have been tested for both CMake projects and MSBuild-based Linux projects with the following distros + shells.<\/p>\n<table style=\"height: 85px; width: 72.6949%; border-collapse: collapse;\" border=\"1\">\n<tbody>\n<tr style=\"height: 28px;\">\n<td style=\"width: 50%; height: 28px;\"><strong>Unix distro<\/strong><\/td>\n<td style=\"width: 50%; height: 28px;\"><strong>Validated shells<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 50%; height: 28px;\">FreeBSD<\/td>\n<td style=\"width: 50%; height: 28px;\">csh, fish, zsh, bash<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 50%; height: 28px;\">Ubuntu (WSL)<\/td>\n<td style=\"width: 50%; height: 28px;\">bash<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 50%; height: 28px;\">Ubuntu 18.04<\/td>\n<td style=\"width: 50%; height: 28px;\">fish, bash, csh, zsh<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 50%; height: 28px;\">Debian (WSL)<\/td>\n<td style=\"width: 50%; height: 28px;\">dash<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h4>Give us your feedback<\/h4>\n<p>Download\u00a0<a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\">Visual Studio 2019 version 16.7 Preview 3<\/a>\u00a0today and give it a try. We\u2019d love to hear from you to help us prioritize and build the right features for you. We can be reached via the comments below,\u00a0<a href=\"https:\/\/developercommunity.visualstudio.com\/spaces\/8\/index.html\">Developer Community<\/a>,\u00a0and Twitter (<a href=\"https:\/\/twitter.com\/visualc\">@VisualC<\/a>). The best way to file a bug or suggest a feature is via Developer Community.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2953,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-26246","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/26246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/2953"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=26246"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/26246\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=26246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=26246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=26246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}