我在 VS 2019 中创建了一个新项目,它无法编译,因为 VS 找不到 Toolset v142 [英] I created a new project in VS 2019 and it doesn't compile because VS fails to find Toolset v142

查看:556
本文介绍了我在 VS 2019 中创建了一个新项目,它无法编译,因为 VS 找不到 Toolset v142的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新项目的模板"是 MFC 动态链接库.问题似乎归结为 Visual Studio 正在寻找文件夹C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Win32\PlatformToolsets\v142".- 不存在的.我已经运行并重新运行 Visual Studio 安装程序 - 总是为工具集 v142 添加更多内容,但似乎没有任何帮助.有没有办法让这个文件夹出现?里面有合适的东西吗?

The 'template' for the new project is MFC Dynamic Link Library. The problem seems to boil down to Visual Studio looking for the folder "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Win32\PlatformToolsets\v142" - which doesn't exist. I have run and re-run the Visual Studio installer - always adding more things for toolset v142, but nothing seems to help. Is there some way to get this folder to appear? With the right stuff in it?

实际上,我正在将现有项目从无数个版本升级回以使用 VS 2019 编译.因为我无法编译它,所以我尝试创建一个新项目来填充旧项目中的文件和在我添加任何文件之前就出现了问题.

In reality, I am upgrading an existing project from umpteen versions back to be compiled with VS 2019. Because I could not get it to compile, I tried to create a new project to stuff with the files from my old project and the problem occurred before I even added any files to it.

我已经做了类似的过程来为以前版本的 VS 编译我的项目,但以前从未遇到过这个问题.任何帮助表示赞赏.

I have done a similar process to compile my project for previous versions of VS, but never had this problem before. Any help appreciated.

推荐答案

为了证明你的问题,我做了一个小测试:

To prove your issue, I have made a small test:

1) 创建一个名为 VCTargetsPath 的新系统环境变量,然后将其值设置为

1) create a new system environment variable called VCTargetsPath and then set its value to

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\

2) 然后重新启动 VS,并将 Platfrom Toolset 设置为 Project Properties 下的 v142​​.

2) then restart VS and also set the the Platfrom Toolset to v142under Project Properties.

3) 然后重建项目并得到同样的错误:

3) then rebuild the project and get the same error:

由于你新创建的项目也有错误,所以我认为你对系统环境变量做了一些更改.

Since you new created project has also the error, so I think you have do some changes to system environment variable.

另外,您应该注意此路径适用于旧的 VS2015.

Also, you should note that this path is for old VS2015.

然而,VS2019 使用:

However, VS2019 uses:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Platforms\Win32\PlatformToolsets\v142

您进行更改以覆盖 VS2019 的系统值,从而导致问题.该值是全局的,会影响您当前 PC 上的所有 vs 版本.

You make a change so that it will overwrite the system value for VS2019 which leads to the issue. The value is global and affects all the vs versions on your current PC.

建议

1)你应该检查你的系统环境变量并搜索VCTargetsPath,如果你有这个变量,请删除它.

1) You should check your system environment variable and search for VCTargetsPath, if you has this variable, please delete it.

2) 或者如果您有此变量 VCTargetsPath,请将其值更改为,如果您没有,则创建它并将其值设置为 VS2019.

2) or if you have this variable VCTargetsPath, change its value to, or if you do not have it, create it and set its value to VS2019.

这篇关于我在 VS 2019 中创建了一个新项目,它无法编译,因为 VS 找不到 Toolset v142的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆