c++cvisual-studiovisual-studio-2019

Make Visual Studio use different minor version Toolset?


Under "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC", I have different directories such as :

However, I noticed Visual Studio always uses the newest minor version.

Can I set it to use an older minor version of the toolset?


Solution

  • You can at a solution level. Following this guide:

    1. Download whatever minor versions you need/want.
    2. Optionally, go to your projects properties and add -Bv as an "Additional Options" in the C/C++ → Command Line menu item. This will output the compiler version upon building.
    3. Go to C:\Program Files (x86)\Microsoft Visual Studio\2019\<yourVisualStudioVersion>\VC\Auxiliary\Build and find the minor version Build.x folder of the minor version you wish to use and open it.
    4. Copy the Microsoft.VCToolsVersion.X.Y.props file (where X is the major version and Y is the minor)
    5. Paste the file into the directory that contains the solution file for your solution.
    6. In Visual Studio, unload your project.
    7. Edit the .vcxproj file of your project and add <Import Project="$(SolutionDir)\Microsoft.VCToolsVersion.X.Y.props" /> just above the line that says <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />.
    8. Reload your project, and perform a test build. If done right, it should be using the minor version specified, which you can see in the output:

    Output

    This should allow you to build against a specific minor version of a major version toolset. The guide also has some other ways, one of which makes use CMake which may be more flexible once configured.