{"id":24826,"date":"2019-08-13T15:04:59","date_gmt":"2019-08-13T15:04:59","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=24826"},"modified":"2019-08-13T15:04:59","modified_gmt":"2019-08-13T15:04:59","slug":"side-by-side-minor-version-msvc-toolsets-in-visual-studio-2019","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2019\/","title":{"rendered":"Side-by-side Minor Version MSVC Toolsets in Visual Studio 2019"},"content":{"rendered":"<p><a href=\"https:\/\/visualstudio.microsoft.com\/vs\/preview\/\">Visual Studio 2019 version 16.1 Preview 3<\/a> ships with the first side-by-side minor versions of the v142 MSVC toolset. We first shipped minor side-by-side versions of MSVC toolsets with Visual Studio 2017, but a few things have changed in 2019. This post covers what\u2019s new; primarily more granular versions of the toolsets in the installer and support for CMake projects.<\/p>\n<p>For those not familiar with these minor version MSVC toolsets, I recommend checking out our <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017\/\">previous post about minor side-by-side toolsets<\/a>. It includes many more details about when and how you should use this feature. In general, you should not need to use these minor versioned toolsets. Instead, the feature is intended as an \u201cescape hatch\u201d for developers who find that there is a bug, either in their source code or in MSVC, that cannot be easily worked around or fixed in a timely fashion. If there\u2019s a conformance issue in your source code, the best option is to\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/cpp-conformance-improvements-2017\">apply the proper fixes to make your code conforming<\/a>\u00a0if possible (sometimes there are too many required changes in your code to fix it all immediately). If you believe that there\u2019s a bug in MSVC, it\u2019s best to talk with us so that we can fix the bug or supply a workaround.<\/p>\n<h3>Installing Minor Version Toolsets<\/h3>\n<p>The biggest change between Visual Studio 2017 and 2019 is in how these minor toolsets are factored. We began breaking toolsets apart by architecture in Visual Studio 2019 and minor toolsets follow this practice too. Whereas in 2017 there was only one minor toolset to install, in 2019 you will need to select all the architectures you build your projects for.<\/p>\n<p>You can install minor versions of the MSVC toolset through the Visual Studio installer. The \u201cDesktop C++ Development\u201d workload will always install the latest version of the toolset. However, if you navigate to the \u201cindividual components\u201d tab in the installer and scroll to \u201cCompilers, build tools, and runtimes\u201d you will see all of the available MSVC toolsets, including the minor versions.<\/p>\n<p>For example, you may see both \u201c(v14.20)\u201d and \u201c(v.14.21)\u201d versions of the \u201cMSVC v142\u201d toolset. In the latest release preview release you will also see &#8220;(v14.22)&#8221; and &#8220;(v14.23)&#8221; the latest.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-24827\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Install-SxS-Toolsets-Annotated.png\" alt=\"Minor versions of the MSVC toolsets in the Visual Studio installer.\" width=\"1200\" height=\"935\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Install-SxS-Toolsets-Annotated.png 1200w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Install-SxS-Toolsets-Annotated-300x234.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Install-SxS-Toolsets-Annotated-768x598.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Install-SxS-Toolsets-Annotated-1024x798.png 1024w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<h3>Using Minor Version Toolsets<\/h3>\n<p>If you are using C++ MSBuild projects, using a minor version of the MSVC toolset has not changed.<\/p>\n<p>Side-by-side minor version MSVC toolsets don\u2019t appear in the \u201cPlatform Toolset\u201d options of the Project Configuration Properties. To enable them you need to edit the\u00a0.vcxproj\u00a0file for your project. Each side-by-side minor version MSVC toolset includes a\u00a0.props\u00a0file that can be included in your project\u2019s\u00a0.vcxproj\u00a0file.<\/p>\n<p>Before you start, you should add the\u00a0-Bv\u00a0compiler option as an Additional Option on the compiler command line. This will show the verbose compiler version information in the build Output box. Just enter \u201c-Bv\u201d in the Project Properties &gt; C\/C++ &gt; Command Line edit box.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-24830\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Compiler-Command-Linx.png\" alt=\"Enable \u201c-Bv\u201d compiler option with project property pages \u201cC\/C++ &gt; Command Line.\u201d\" width=\"1676\" height=\"1195\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Compiler-Command-Linx.png 1676w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Compiler-Command-Linx-300x214.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Compiler-Command-Linx-768x548.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Compiler-Command-Linx-1024x730.png 1024w\" sizes=\"(max-width: 1676px) 100vw, 1676px\" \/><\/p>\n<p>Now, open the \u201cVC\\Auxiliary\\Build14.20\u201d directory in the folder where you installed Visual Studio version 16.1 Preview 3. For example, using the default install location you\u2019ll find it here: \u201cC:\\Program Files (x86)\\Microsoft Visual Studio\\Preview\\Enterprise\\VC\\Auxiliary\\Build14.20.\u201d You should see three files in this folder. You\u2019ll need to copy one of them, \u201cMicrosoft.VCToolsVersion.14.20.props,\u201d into your solution directory.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-24832\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Props-Build-Aux.png\" alt=\"Copy the toolsets \u201c.props\u201d file.\" width=\"827\" height=\"512\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Props-Build-Aux.png 827w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Props-Build-Aux-300x186.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Props-Build-Aux-768x475.png 768w\" sizes=\"(max-width: 827px) 100vw, 827px\" \/><\/p>\n<p>Next, open the folder containing your solution by right-clicking on the solution and selecting \u201cOpen Folder in File Explorer\u201d.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-24834\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Open-project-directory.png\" alt=\"Open the project directory.\" width=\"2731\" height=\"1742\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Open-project-directory.png 2731w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Open-project-directory-300x191.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Open-project-directory-768x490.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Open-project-directory-1024x653.png 1024w\" sizes=\"(max-width: 2731px) 100vw, 2731px\" \/><\/p>\n<p>Copy the \u201cMicrosoft.VCToolsVersion.14.20.props\u201d into your solution directory. The file should sit in the same directory as your project\u2019s solution file, e.g., Project6.sln.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-24838\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Props-Project-Dir.png\" alt=\"Copy the toolset\u2019s \u201c.props\u201d file to the project directory.\" width=\"827\" height=\"512\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Props-Project-Dir.png 827w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Props-Project-Dir-300x186.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/Props-Project-Dir-768x475.png 768w\" sizes=\"(max-width: 827px) 100vw, 827px\" \/><\/p>\n<p>Now unload your project by right-clicking on the project and selecting \u201cUnload Project\u201d. Once the project is unloaded, you can edit the project by clicking on it and selecting \u201cEdit [ProjectName]\u201d. Locate the line that says:<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" \/&gt;<\/pre>\n<p>Add a line directly\u00a0<i>above<\/i>\u00a0this line that imports the\u00a0Microsoft.VCToolsVersion.14.20.props\u00a0that you just copied into the solution directory:<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;Import Project=\"$(SolutionDir)\\Microsoft.VCToolsVersion.14.20.props\" \/&gt;\r\n&lt;Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" \/&gt;\r\n<\/pre>\n<p>Now, save the file, then right-click on the project name and select \u201cReload Project\u201d. If you haven\u2019t already saved the file, you\u2019ll be prompted to close the open .vcxproj file. Select \u201cYes\u201d to close the file. Now when you rebuild the solution, you\u2019ll see that you\u2019re using the 14.20 MSVC compiler toolset.<\/p>\n<h3>Using Minor Version Toolsets with CMake<\/h3>\n<p>You can also seamlessly use these toolsets with <a href=\"https:\/\/aka.ms\/cmake\">CMake projects<\/a> in Visual Studio too. To do this, you will need to create an environment variable in your CMakeSettings file called \u201cVCToolsVersion\u201d and set it to the minor version you need to use, for example \u201c14.20.\u201d To do this, you will need to modify the JSON of the CMake Settings file directly. If you are in in the CMake Settings editor, you can access the JSON with the \u201cEdit JSON\u201d button in the top right corner.<\/p>\n<p>Now, you just need to delete the cache \u201cProject &gt; CMake Cache &gt; Delete Cache\u201d and regenerate it \u201cProject &gt; Generate Cache.\u201d You can confirm that CMake is using the right toolset by examining the compiler path in the Output Window.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-24840\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/CMakeToolset.png\" alt=\"Toolset 14.20 being used instead of the latest version 14.23 with the \u201cVCToolsVersion\u201d variable.\" width=\"1301\" height=\"1191\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/CMakeToolset.png 1301w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/CMakeToolset-300x275.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/CMakeToolset-768x703.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2019\/08\/CMakeToolset-1024x937.png 1024w\" sizes=\"(max-width: 1301px) 100vw, 1301px\" \/><\/p>\n<p>If you are working with CMake projects outside of the IDE, you can still use minor versions of the MSVC toolsets. Follow the instructions below for setting up a command line to use the toolset you need, and then just run CMake to configure the project. Once the project is configured, the minor toolset selected will be saved in the CMake cache and can then be used from any environment.<\/p>\n<h3>Using Minor Version Toolsets with the Command Line<\/h3>\n<p>If\u00a0you need to use a side-by-side minor version MSVC toolset from the command line you just need to customize a developer command prompt. The command prompts installed with Visual Studio 2019 version 16.1 Preview 3 are located in the\u00a0VC\\Auxiliary\\Build\u00a0subdirectory of your VS install dir. For example, with the default installation path, they are located in the\u00a0C:\\Program Files (x86)\\Microsoft Visual Studio\\Preview\\Enterprise\\VC\\Auxiliary\\Build\u00a0directory.<\/p>\n<p>In that folder you\u2019ll find four developer command prompts (named\u00a0vcvars*.bat). Pick any one and create a copy to edit. The contents of these files are pretty simple: they all just invoke\u00a0vcvarsall.bat with the proper architecture parameter. We\u2019ll do the same, but add a new parameter that tells\u00a0vcvarsall.bat\u00a0to set up the environment for the v14.20 toolset:\u00a0-vcvars_ver=14.20.<\/p>\n<p>You can run \u201ccl -Bv\u201d to show that the environment is set up for the right version of the tools.<\/p>\n<p>We\u2019d love for you to <a href=\"https:\/\/visualstudio.microsoft.com\/vs\/\">download Visual Studio 2019<\/a> and give it a try. As always, we welcome your feedback. We can be reached via the comments below or via email (<a href=\"mailto:visualcpp@microsoft.com\" target=\"_blank\" rel=\"noopener noreferrer\">visualcpp@microsoft.com<\/a>). If you encounter problems with Visual Studio or MSVC, or have a suggestion for us, please let us know through <strong>Help &gt; Send Feedback &gt; Report A Problem \/ Provide a Suggestion<\/strong> in the product, or via <a href=\"https:\/\/developercommunity.visualstudio.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Developer Community<\/a>. You can also find us on Twitter (<a href=\"https:\/\/twitter.com\/visualc\" target=\"_blank\" rel=\"noopener noreferrer\">@VisualC<\/a>).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio 2019 version 16.1 Preview 3 ships with the first side-by-side minor versions of the v142 MSVC toolset. We first shipped minor side-by-side versions of MSVC toolsets with Visual Studio 2017, but a few things have changed in 2019. This post covers what\u2019s new; primarily more granular versions of the toolsets in the installer [&hellip;]<\/p>\n","protected":false},"author":326,"featured_media":24828,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[216],"tags":[],"class_list":["post-24826","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-documentation"],"acf":[],"blog_post_summary":"<p>Visual Studio 2019 version 16.1 Preview 3 ships with the first side-by-side minor versions of the v142 MSVC toolset. We first shipped minor side-by-side versions of MSVC toolsets with Visual Studio 2017, but a few things have changed in 2019. This post covers what\u2019s new; primarily more granular versions of the toolsets in the installer [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/24826","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\/326"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=24826"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/24826\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/24828"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=24826"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=24826"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=24826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}