Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 716
Anders Gustafsson Avatar asked Jan 27 '23 12:01

Anders Gustafsson


2 Answers

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).

like image 97
Ben-Coden Avatar answered Jan 30 '23 08:01

Ben-Coden


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.

like image 29
Anders Gustafsson Avatar answered Jan 30 '23 09:01

Anders Gustafsson