{"id":11836,"date":"2016-11-16T13:00:56","date_gmt":"2016-11-16T20:00:56","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=11836"},"modified":"2019-02-18T18:04:33","modified_gmt":"2019-02-18T18:04:33","slug":"open-any-folder-with-c-sources-in-visual-studio-2017-rc","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/open-any-folder-with-c-sources-in-visual-studio-2017-rc\/","title":{"rendered":"Open any folder with C++ sources in Visual Studio 2017 RC"},"content":{"rendered":"<p>With the <a href=\"https:\/\/www.visualstudio.com\/visual-studio-pre-release-downloads\/\">Visual Studio 2017 RC release<\/a>, we&#8217;re continuing to improve the &#8220;Open Folder&#8221; capabilities for C++ source code. In this release, we&#8217;re adding support for building as well as easier configuration for the debugger and the C++ language services.<\/p>\n<p>If you are just getting started with &#8220;Open Folder&#8221; or want to read about these capabilities in more depth, head over to the <a href=\"https:\/\/aka.ms\/openfolder\/cpp\">Open Folder for C++ introductory post<\/a>\u00a0that has been updated with the content below. If you are using CMake, head over to our blog post introducing the\u00a0<a href=\"https:\/\/aka.ms\/cmake\">CMake support in Visual Studio<\/a>.<\/p>\n<p>Here are the improvements for the \u201cOpen Folder\u201d C++ experience in the new RC release for Visual Studio 2017:<\/p>\n<ul>\n<li><a href=\"#read-code\">Reading and editing C++ code<\/a><\/li>\n<li><a href=\"#build-code\">Building C++ projects<\/a><\/li>\n<li><a href=\"#debug-code\">Debugging C++ binaries<\/a><\/li>\n<\/ul>\n<h3><a>Reading and editing C++ Code<\/a><\/h3>\n<p><strong>Environment variables and macros support<\/strong>. <em>CppProperties.json <\/em>file, which aids in configuring C++ IntelliSense and browsing, now supports environment variable expansion for include paths or other property values. The syntax is ${env.FOODIR} to expand an environment variable %FOODIR%<\/p>\n<p><strong>CppProperties.json<\/strong>:<\/p>\n<pre class=\"prettyprint\">{\n  &quot;configurations&quot;: [\n    {\n      &quot;name&quot;: &quot;Windows&quot;,\n      &quot;includePath&quot;: [ \/\/ include UCRT and CRT headers\n        &quot;${env.WindowsSdkDir}include\\\\${env.WindowsSDKVersion}\\\\ucrt&quot;,\n        &quot;${env.VCToolsInstallDir}include&quot;\n      ]\n    }\n  ]\n}<\/pre>\n<p><strong>Note<\/strong>: %WindowsSdkDir% and %VCToolsInstallDir% are not set as global environment variables so make sure you start devenv.exe from a &#8220;Developer Command Prompt for VS 2017&#8221; that defines these variables.<\/p>\n<p>You also have access to built-in macros inside this file:<\/p>\n<ul>\n<li><em>${workspaceRoot}<\/em> \u2013 provides the full path to the workspace folder<\/li>\n<li><em>${projectRoot}<\/em> \u2013 full path to the folder where CppProperties.json is placed<\/li>\n<li><em>${vsInstallDir}<\/em> \u2013 full path to the folder where the running instance of VS 2017 is installed<\/li>\n<\/ul>\n<p><strong>CppProperties.json IntelliSense.<\/strong> Get assistance while editing CppProperties.json via JSON IntelliSense when you have the full-fledged JSON editor installed (it comes with the Web Development Workload)<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-cppprops-intellisense.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-cppprops-intellisense.png\" alt=\"anycode-rc0-cppprops-intellisense\" width=\"672\" height=\"250\" class=\"alignnone size-full wp-image-11855\" \/><\/a><\/p>\n<p><strong>C++ Configuration dropdown<\/strong>. You can create as many configurations as you want in CppProperties.json and easily switch between them from the C++ configuration dropdown in the Standard toolbar<\/p>\n<p><strong>CppProperties.json<\/strong><\/p>\n<pre class=\"prettyprint\">{\n  &quot;configurations&quot;: [\n    {\n      &quot;name&quot;: &quot;Windows&quot;,\n      ...\n    },\n    {\n      &quot;name&quot;: &quot;with EXTERNAL_CODECS&quot;,\n      ...\n    }\n  ]\n}<\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-cppconfig-dropdown.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-cppconfig-dropdown.png\" alt=\"anycode-rc0-cppconfig-dropdown\" width=\"701\" height=\"128\" class=\"alignnone size-full wp-image-11845\" \/><\/a><\/p>\n<p><strong>CppProperties.json is now optional<\/strong> and by default, when you open a folder with C++ source code, VS will create 2 default C++ configurations: Debug and Release. These configurations are consistent with the configurations provided by the <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/single-file-intellisense-and-other-ide-improvements-in-vs2015\/\">Single File IntelliSense<\/a> we introduced in VS 2015.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-default-config.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-default-config.png\" alt=\"anycode-rc0-default-config\" width=\"551\" height=\"254\" class=\"alignnone size-full wp-image-11865\" \/><\/a><\/p>\n<h3><a>Building C++ projects<\/a><\/h3>\n<p><strong>Integrate external tools via tasks<\/strong>. You can now automate build scripts or any other external operations on the files you have in your current workspace by running them as tasks directly in the IDE. You can configure a new task by right clicking on a file or folder and select &#8220;Customize Task Settings&#8221;.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-menu.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-menu.png\" alt=\"anycode-rc0-tasksjson-menu\" width=\"453\" height=\"463\" class=\"alignnone size-full wp-image-11915\" \/><\/a><\/p>\n<p>This will create a new file <em>tasks.vs.json<\/em> under the hidden .vs folder in your workspace and a new task that you can customize. JSON IntelliSense is available if you have the JSON editor installed (it comes with the Web Development workload)<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-intellisense.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-intellisense.png\" alt=\"anycode-rc0-tasksjson-intellisense\" width=\"632\" height=\"248\" class=\"alignnone size-full wp-image-11905\" \/><\/a><\/p>\n<p>By default, a task can be executed from the context menu of the file in Solution Explorer. For each task, you will find a new entry at the bottom of the context menu.<\/p>\n<p><strong>Tasks.vs.json<\/strong><\/p>\n<pre class=\"prettyprint\">{\n  &quot;version&quot;: &quot;0.2.1&quot;,\n  &quot;tasks&quot;: [\n    {\n      &quot;taskName&quot;: &quot;Echo filename&quot;,\n      &quot;appliesTo&quot;: &quot;makefile&quot;,\n      &quot;type&quot;: &quot;command&quot;,\n      &quot;command&quot;: &quot;${env.COMSPEC}&quot;,\n      &quot;args&quot;: [&quot;echo ${file}&quot;]\n    }\n  ]\n}<\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-contextmenu.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-contextmenu.png\" alt=\"anycode-rc0-tasksjson-contextmenu\" width=\"451\" height=\"484\" class=\"alignnone size-full wp-image-11895\" \/><\/a><\/p>\n<p><strong>Environment variables support and macros<\/strong>. Just like CppProperties.json, in tasks.vs.json you can consume environment variables by using the syntax ${env.VARIABLE}.<\/p>\n<p>Additionally, you can use built-in macros inside your tasks properties:<\/p>\n<ul>\n<li><em>${workspaceRoot}<\/em> \u2013 provides the full path to the workspace folder<\/li>\n<li><em>${file}<\/em> \u2013 provides the full path to the file or folder selected to run this task against<\/li>\n<\/ul>\n<p>You can also specify additional user macros yourself that you can use in the tasks properties e.g. ${outDir} in the example below:<\/p>\n<p><strong>Tasks.vs.json<\/strong><\/p>\n<pre class=\"prettyprint\">{\n  &quot;version&quot;: &quot;0.2.1&quot;,\n  &quot;outDir&quot;: &quot;${workspaceRoot}\\\\bin&quot;,\n  &quot;tasks&quot;: [\n    {\n      &quot;taskName&quot;: &quot;List outputs&quot;,\n      &quot;appliesTo&quot;: &quot;*&quot;,\n      &quot;type&quot;: &quot;command&quot;,\n      &quot;command&quot;: &quot;${env.COMSPEC}&quot;,\n      &quot;args&quot;: [ &quot;dir ${outDir}&quot; ]\n    }\n  ]\n}<\/pre>\n<p><strong>Building projects<\/strong>. By specifying the &#8220;contextType&#8221; for a given task to equal &#8220;build&#8221;, &#8220;clean&#8221; or &#8220;rebuild&#8221; you can wire up the VS build-in commands for Build, Clean and Rebuild that can be invoked from the context menu.<\/p>\n<p><strong>Tasks.vs.json<\/strong><\/p>\n<pre class=\"prettyprint\">{\n  &quot;version&quot;: &quot;0.2.1&quot;,\n  &quot;tasks&quot;: [\n    {\n      &quot;taskName&quot;: &quot;makefile-build&quot;,\n      &quot;appliesTo&quot;: &quot;makefile&quot;,\n      &quot;type&quot;: &quot;command&quot;,\n      &quot;contextType&quot;: &quot;build&quot;,\n      &quot;command&quot;: &quot;nmake&quot;\n    },\n    {\n      &quot;taskName&quot;: &quot;makefile-clean&quot;,\n      &quot;appliesTo&quot;: &quot;makefile&quot;,\n      &quot;type&quot;: &quot;command&quot;,\n      &quot;contextType&quot;: &quot;clean&quot;,\n      &quot;command&quot;: &quot;nmake&quot;,\n      &quot;args&quot;: [&quot;clean&quot;]\n    }\n  ]\n}<\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-build.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-build.png\" alt=\"anycode-rc0-tasksjson-build\" width=\"454\" height=\"503\" class=\"alignnone size-full wp-image-11885\" \/><\/a><\/p>\n<p><strong>File and folder masks<\/strong>. You can create tasks for any file or folder by specifying its name in the &#8220;appliesTo&#8221; field. But to create more generic tasks you can use file masks. For example:<\/p>\n<ul>\n<li><em>&#8220;appliesTo&#8221;: &#8220;*&#8221;<\/em> \u2013 task is available to all files and folders in the workspace<\/li>\n<li><em>&#8220;appliesTo&#8221;: &#8220;*\/&#8221;<\/em> \u2013 task is available to all folders in the workspace<\/li>\n<li><em>&#8220;appliesTo&#8221;: &#8220;*.cpp&#8221;<\/em> \u2013 task is available to all files with the extension .cpp in the workspace<\/li>\n<li><em>&#8220;appliesTo&#8221;:\u00a0&#8220;\/*.cpp&#8221;<\/em> \u2013 task is available to all files with the extension .cpp in the root of the workspace<\/li>\n<li><em>&#8220;appliesTo&#8221;: &#8220;src\/*\/&#8221;<\/em> \u2013 task is available to all subfolders of the \u201csrc\u201d folder<\/li>\n<li><em>&#8220;appliesTo&#8221;: &#8220;makefile&#8221;<\/em> \u2013 task is available to all makefile files in the workspace<\/li>\n<li><em>&#8220;appliesTo&#8221;: &#8220;\/makefile&#8221;<\/em> \u2013 task is available only on the makefile in the root of the workspace<\/li>\n<\/ul>\n<h3><a>Debugging C++ binaries<\/a><\/h3>\n<p><strong>Debug task outputs.<\/strong> If you specify an output binary in your task definition (via \u201coutput\u201d), this binary will be automatically launched under the debugger if you select the source file as a startup item or just right click on the source file and choose \u201cDebug\u201d. E.g.<\/p>\n<p><strong>Tasks.vs.json<\/strong><\/p>\n<pre class=\"prettyprint\">{\n  &quot;version&quot;: &quot;0.2.1&quot;,\n  &quot;tasks&quot;: [\n    {\n      &quot;taskName&quot;: &quot;makefile-build&quot;,\n      &quot;appliesTo&quot;: &quot;makefile&quot;,\n      &quot;type&quot;: &quot;command&quot;,\n      &quot;contextType&quot;: &quot;build&quot;,\n      &quot;command&quot;: &quot;nmake&quot;,\n      &quot;output&quot;: &quot;${workspaceRoot}\\\\bin\\\\hellomake.exe&quot;\n    }\n  ]\n}<\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-output.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/anycode-rc0-tasksjson-output.png\" alt=\"anycode-rc0-tasksjson-output\" width=\"455\" height=\"385\" class=\"alignnone size-full wp-image-11925\" \/><\/a><\/p>\n<h3>What\u2019s next<\/h3>\n<p><a href=\"https:\/\/www.visualstudio.com\/visual-studio-pre-release-downloads\/\">Download Visual Studio 2017 RC today<\/a> and please try the \u201cOpen Folder\u201d experience. For an overview of the \u201cOpen Folder\u201d experience, also check out the <a href=\"https:\/\/aka.ms\/openfolder\/cpp\">\u201cOpen Folder\u201d for C++ overview blog post<\/a>.<\/p>\n<p>As we\u2019re continuing to evolve the \u201cOpen Folder\u201d support, we want your input to make sure the experience meets your needs when bringing C++ codebases that use non-MSBuild build systems into Visual Studio, so don\u2019t hesitate to contact us. We look forward to hearing from you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the Visual Studio 2017 RC release, we&#8217;re continuing to improve the &#8220;Open Folder&#8221; capabilities for C++ source code. In this release, we&#8217;re adding support for building as well as easier configuration for the debugger and the C++ language services. If you are just getting started with &#8220;Open Folder&#8221; or want to read about these [&hellip;]<\/p>\n","protected":false},"author":308,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[270,269],"tags":[8,140,339,308,6,309,268,185],"class_list":["post-11836","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","category-openfolder","tag-announcement","tag-c","tag-cppproperties-json","tag-existing-code","tag-ide","tag-import","tag-openfolder","tag-visual-studio"],"acf":[],"blog_post_summary":"<p>With the Visual Studio 2017 RC release, we&#8217;re continuing to improve the &#8220;Open Folder&#8221; capabilities for C++ source code. In this release, we&#8217;re adding support for building as well as easier configuration for the debugger and the C++ language services. If you are just getting started with &#8220;Open Folder&#8221; or want to read about these [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/11836","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\/308"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=11836"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/11836\/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=11836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=11836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=11836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}