【问题标题】:Error MSB4062: The "SetEnv" task could not be loaded from the assembly错误 MSB4062:无法从程序集中加载“SetEnv”任务
【发布时间】:2018-09-29 14:07:32
【问题描述】:

所以我正在尝试安装一个名为 better-sqlite-pool 的 Node 包,但是我遇到了一个似乎无法解决的错误。每当我运行 npm i 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]

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

我收到的第一个错误通过添加 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.

我尝试的另一件事是使用 npm install -g --production windows-build-tools 命令安装构建工具,但这并没有什么不同。

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

【问题讨论】:

    标签: node.js visual-studio msbuild


    【解决方案1】:

    我有一个rather similar issue,并且在同一时间有货。我找到了两种可能的解决方案over here

    • 同时安装 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

    由于我不是真正的程序员,我不知道从哪里开始选择后一种选择。

    【讨论】:

    • "s" 不见了!它是“windows-build-tools”
    【解决方案2】:

    您不需要完整的 2015 与您可以安装 msbuild 2015 组件 https://www.microsoft.com/en-us/download/details.aspx?id=48159 您可能需要确保在您的路径中使用添加的 msbuild

    如果未找到新的 msbuild(即使在重新启动后),您可能会使用类似的命令

    set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
    

    在 cmd.exe 中

    【讨论】:

      猜你喜欢
      • 2018-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 2012-07-30
      • 1970-01-01
      • 2017-12-09
      • 2016-01-13
      相关资源
      最近更新 更多