Build fails for C++/CX project with v141 platform toolset in Visual Studio 2019
Asked Answered
P

3

6

I have tried to switch to Visual Studio 2019 since it is now officially released, but I am having problems building a C++/CX based project.

I have not retargeted the project, but it is still configured to use the v141 platform toolset, i.e. Visual Studio 2017 Build Tools.

As far as I can tell, I have specifically installed the required build tools in Visual Studio 2019, which should be evident here:

enter image description here enter image description here

Still, according to the project properties, Visual Studio 2017 Build Tools are not installed:

enter image description here

And when I build the project I get the following error:

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(378,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 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".

Am I still missing some components in my installation, or is this a bug in Visual Studio 2019?

EDIT I should point out that I still have Visual Studio 2017 installed on the same computer as well.

Pavyer answered 4/4, 2019 at 7:19 Comment(1)
Going through a similar issue, one thing worth pointing out is that in your error from compilation you can see that v160 is included in the path being used (VS2019 tools) whereas the value should be v150 (VS2017 tools). Thus the proper v141 MSVC++ toolset is not being found as that will ultimately be colocated with the VS2017 tools.Halophyte
P
3

It turns out that the (Windows Runtime Component) project was not properly set up. In the .vcxproj file the ApplicationTypeRevision element was missing, which is also "evident" (if you know what you are looking for...) from looking at the project properties above, where only the General configuration properties node is visible, and the Target Platform value is empty.

Inserting the following line in the .vcxproj file immediately following e.g. the WindowsTargetPlatformMinVersion element should do the trick:

<ApplicationTypeRevision>10.0</ApplicationTypeRevision>

Most likely, it was also necessary to add the C++ Universal Windows Platform Tools. The v142 version was made available when trying to create a new C++ Universal Windows Platform project. As far as I could tell, this component was not otherwise visible in the Visual Studio Installer? Once the v142 component was installed, the corresponding v141 component was also available for installation.

Pavyer answered 4/4, 2019 at 13:26 Comment(0)
D
8

enter image description here

I had a similar issue, but this is what I was missing.

You will find these options on the Workloads tab of the VS installer on the right under Installation details (i.e. not under Individual components).

Dismissal answered 19/5, 2019 at 5:23 Comment(1)
Thanks Ben! Was pulling my hair out trying to figure out why it kept giving me an error when I thought I clearly had v141 build tools installed.Flourish
P
3

It turns out that the (Windows Runtime Component) project was not properly set up. In the .vcxproj file the ApplicationTypeRevision element was missing, which is also "evident" (if you know what you are looking for...) from looking at the project properties above, where only the General configuration properties node is visible, and the Target Platform value is empty.

Inserting the following line in the .vcxproj file immediately following e.g. the WindowsTargetPlatformMinVersion element should do the trick:

<ApplicationTypeRevision>10.0</ApplicationTypeRevision>

Most likely, it was also necessary to add the C++ Universal Windows Platform Tools. The v142 version was made available when trying to create a new C++ Universal Windows Platform project. As far as I could tell, this component was not otherwise visible in the Visual Studio Installer? Once the v142 component was installed, the corresponding v141 component was also available for installation.

Pavyer answered 4/4, 2019 at 13:26 Comment(0)
M
1

I had this same problem for Visual Studio 2017, even though V141 was explicitly shown as installed. It turned out the problem was that VCTargetsPath was set in System Environment Variables to "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\V4.0\V140". Removing or unsetting this variable solved the issue.

I suspect this variable was set during an earlier install of Visual Studio 2015. Even after uninstalling all other Visual Studios the variable was never removed and the problem persisted.

Munch answered 8/4, 2020 at 21:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.