Open any folder with C++ sources in Visual Studio 2017 RC

Marian Luparu


With the Visual Studio 2017 RC release, we’re continuing to improve the “Open Folder” capabilities for C++ source code. In this release, we’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 “Open Folder” or want to read about these capabilities in more depth, head over to the Open Folder for C++ introductory post that has been updated with the content below. If you are using CMake, head over to our blog post introducing the CMake support in Visual Studio.

Here are the improvements for the “Open Folder” C++ experience in the new RC release for Visual Studio 2017:

Reading and editing C++ Code

Environment variables and macros support. CppProperties.json 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%


[js]{ "configurations": [ { "name": "Windows", "includePath": [ // include UCRT and CRT headers "${env.WindowsSdkDir}include\\${env.WindowsSDKVersion}\\ucrt", "${env.VCToolsInstallDir}include" ] } ] }[/js]

Note: %WindowsSdkDir% and %VCToolsInstallDir% are not set as global environment variables so make sure you start devenv.exe from a “Developer Command Prompt for VS 2017” that defines these variables.

You also have access to built-in macros inside this file:

  • ${workspaceRoot} – provides the full path to the workspace folder
  • ${projectRoot} – full path to the folder where CppProperties.json is placed
  • ${vsInstallDir} – full path to the folder where the running instance of VS 2017 is installed

CppProperties.json IntelliSense. 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)


C++ Configuration dropdown. 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


[js]{ "configurations": [ { "name": "Windows", … }, { "name": "with EXTERNAL_CODECS", … } ] }[/js]


CppProperties.json is now optional 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 Single File IntelliSense we introduced in VS 2015.


Building C++ projects

Integrate external tools via tasks. 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 “Customize Task Settings”.


This will create a new file tasks.vs.json 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)


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.


[js]{ "version": "0.2.1", "tasks": [ { "taskName": "Echo filename", "appliesTo": "makefile", "type": "command", "command": "${env.COMSPEC}", "args": ["echo ${file}"] } ] }[/js]


Environment variables support and macros. Just like CppProperties.json, in tasks.vs.json you can consume environment variables by using the syntax ${env.VARIABLE}.

Additionally, you can use built-in macros inside your tasks properties:

  • ${workspaceRoot} – provides the full path to the workspace folder
  • ${file} – provides the full path to the file or folder selected to run this task against

You can also specify additional user macros yourself that you can use in the tasks properties e.g. ${outDir} in the example below:


[js]{ "version": "0.2.1", "outDir": "${workspaceRoot}\\bin", "tasks": [ { "taskName": "List outputs", "appliesTo": "*", "type": "command", "command": "${env.COMSPEC}", "args": [ "dir ${outDir}" ] } ] }[/js]

Building projects. By specifying the “contextType” for a given task to equal “build”, “clean” or “rebuild” you can wire up the VS build-in commands for Build, Clean and Rebuild that can be invoked from the context menu.


[js]{ "version": "0.2.1", "tasks": [ { "taskName": "makefile-build", "appliesTo": "makefile", "type": "command", "contextType": "build", "command": "nmake" }, { "taskName": "makefile-clean", "appliesTo": "makefile", "type": "command", "contextType": "clean", "command": "nmake", "args": ["clean"] } ] }[/js]


File and folder masks. You can create tasks for any file or folder by specifying its name in the “appliesTo” field. But to create more generic tasks you can use file masks. For example:

  • “appliesTo”: “*” – task is available to all files and folders in the workspace
  • “appliesTo”: “*/” – task is available to all folders in the workspace
  • “appliesTo”: “*.cpp” – task is available to all files with the extension .cpp in the workspace
  • “appliesTo”: “/*.cpp” – task is available to all files with the extension .cpp in the root of the workspace
  • “appliesTo”: “src/*/” – task is available to all subfolders of the “src” folder
  • “appliesTo”: “makefile” – task is available to all makefile files in the workspace
  • “appliesTo”: “/makefile” – task is available only on the makefile in the root of the workspace

Debugging C++ binaries

Debug task outputs. If you specify an output binary in your task definition (via “output”), 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 “Debug”. E.g.


[js]{ "version": "0.2.1", "tasks": [ { "taskName": "makefile-build", "appliesTo": "makefile", "type": "command", "contextType": "build", "command": "nmake", "output": "${workspaceRoot}\\bin\\hellomake.exe" } ] }[/js]


What’s next

Download Visual Studio 2017 RC today and please try the “Open Folder” experience. For an overview of the “Open Folder” experience, also check out the “Open Folder” for C++ overview blog post.

As we’re continuing to evolve the “Open Folder” 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’t hesitate to contact us. We look forward to hearing from you!


Comments are closed. Login to edit/delete your existing comments