错误MSB4062:无法从程序集中加载“ SetEnv”任务

Luk*_*uke 1 msbuild visual-studio node.js

因此,我尝试安装一个名为Better-sqlite-pool的Node包,但是遇到了我似乎无法解决的错误。每当我运行npm我better-sqlite-pool时,都会出现以下错误:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\Microsoft.Cpp.Current.targets(64,5): error MSB4062: The "SetEnv"
 task could not be loaded from the assembly C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\Microsoft.Build.CppT
asks.Common.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, Pu
blicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the
<UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contain
s a public class that implements Microsoft.Build.Framework.ITask. [D:\Files\ScrimsBot\node_modules\integer\build\intege
r.vcxproj]
Run Code Online (Sandbox Code Playgroud)

我对此进行了广泛的研究,并且尝试了几乎所有建议的修补程序,但均未成功。

我收到的第一个错误设法通过添加VCTargetsPath环境变量并将其设置为C:\ Program Files(x86)\ MSBuild \ Microsoft.Cpp \ v4.0 \ v140来解决。在执行此操作之前,我收到以下错误:

The imported project "D:\Microsoft.
Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exist
s on disk.
Run Code Online (Sandbox Code Playgroud)

我尝试过的另一件事是使用npm install -g --production Windows-build-tools命令安装构建工具,但这没什么区别。

可能值得注意的是,我已经安装了Visual Studio 2017 Enterprise,并且安装了用于桌面组件的VC ++ 2015.3 v14.00(v140)工具集

小智 6

我有一个非常相似的问题,并且在同一时间得到了库存。我在这里找到了两种可能的解决方案:

  • 同时安装Visual Studio 2015
  • 在与exe相同的目录中创建.config文件(如果尚未安装),其中包含msbuild程序集的绑定重定向

第一个选项对我有用:

  • 使用当前用户的管理员提示,而不是受限用户的权限,如果这样做,那么路径将是一团糟
  • npm install --global --production --vs2015 windows-build-tools
  • npm install --global --production windows-build-tools (这个在安装过程中卡住了,请使用ctrl-c结束安装)
  • npm install --global --production windows-build-tools (是的,再次使用同一命令完成配置)
  • npm config set msvs_version 2015 --global

因为我不是一个真正的程序员,所以我不知道从后一种选择开始。