2

When I try to compile some C++ code I get the error

Code:   
    MSB8020
Description:    
    The build tools for v150 (Platform Toolset = 'v150') cannot be found. 
    To build using the v150 build tools, please install v150 build tools.  
    Alternatively, you may upgrade to the current Visual Studio tools by 
    selecting the Project menu or right-click the solution, and then 
    selecting "Retarget solution".

I cannot select "Retarget solution" as there is no such.
I have opened the Visual studio installer but the latest toolset there is 141.

How do I downgrade the build tools requirement or how do I "Retarget solution"?

TL;DR

I got into this situation by trying to compile Autohotkey_L. I did it totally clean by installing a HyperV virtual machine and downloading the dev machine Microsoft has provided. It already contains a Visual studio 2017 community edition. It can't get more clean or more latest than that.

LosManos
  • 7,195
  • 6
  • 56
  • 107
  • 1
    https://stackoverflow.com/questions/20292810/visual-studio-wants-to-build-with-wrong-platform-toolset – HaveSpacesuit Jun 19 '18 at 20:20
  • To be more precise to @HaveSpacesuit 's answer, go to [the answer](https://stackoverflow.com/a/20293163/521554). Or rather, the answer to this question. – LosManos Jun 23 '18 at 21:31

1 Answers1

7

You are using Visual Studio 2017 with 141 toolset by default (you can also install v140 additionally). v150 will be probably available in the future versions, that's why you can still select it in the Toolsets.

The issue is when toolset is not selected, it is trying to use the highest version for your visual studio version without looking at if the toolset is installed or not. As 150 is not available yet, you can't use it.

In order to fix it, right click on the projects (not solutions!), you should have 2 for your example, go Properties -> select Configuration-All configurations -> General -> Platform toolset -> select v141 (as you should have it by default) -> OK. Perform it with a second project you have as well.

Here is how it looks like:

visual studio configuration screenshot

Stan E
  • 3,396
  • 20
  • 31