1

我在 Visual Studio 2015 社区版中构建 Qt 5.8 项目时遇到此错误,我无法解决此问题。

1>------ Rebuild All started: Project: analogclock, Configuration: Debug Win32 ------
1>  Generate moc_predefs.h
1>  Reading Qt configuration (D:\Qt\Qt5.8.0\5.8\msvc2015\bin\qmake.exe)
1>C:\Users\Dan\AppData\Local\QtMsBuild\qt_vars.targets(246,5): error : The source file for this compilation can be found at:
 "C:\Users\Dan\AppData\Local\Temp\25ee8a4c-842c-4329-96bc-cd757b4f3616.txt"
1>C:\Users\Dan\AppData\Local\QtMsBuild\qt_vars.targets(246,5): error MSB3758: 
    An error has occurred during compilation. warning CS1668: Invalid search path 'Lib\um\x86' 
    specified in 'LIB environment variable' -- 'The system cannot find the path specified. '
1>C:\Users\Dan\AppData\Local\QtMsBuild\qt_vars.targets(246,5): error MSB3758:
     An error has occurred during compilation. c:\Users\Dan\AppData\Local\Temp\qmousnkh.0.cs(88,26) : error CS1061: 
    'System.Collections.Generic.IEnumerable<string>' does not contain a definition for 'ToHashSet' 
    and no extension method 'ToHashSet' accepting a first argument of type 'System.Collections.Generic.IEnumerable<string>' 
    could be found (are you missing a using directive or an assembly reference?)
1>C:\Users\Dan\AppData\Local\QtMsBuild\qt_vars.targets(246,5): error MSB4036: 
    The "GetVarsFromMakefile" task was not found. Check the following: 
    1.) The name of the task in the project file is the same as the name of the task class. 
    2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 
    3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks 
        files located in the "C:\Program Files\MSBuild\14.0\bin" directory.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
4

1 回答 1

1

我有同样的错误,我希望我的解决方案可以帮助你(尽管你问的时候已经过去了将近一年:-))或其他人。不久 - 尝试将 .Net Framework 至少更新到版本 4.7.2。

经过一番调查,我发现 QT VS Tools 在自定义构建脚本中使用了 C# 代码片段。其中之一是文件 qt_vars.targets 中的 GetVarsFromMakefile。我将此代码复制到新的 C# 项目中,添加了缺少的变量,并且在编译 QT 项目期间出现了相同的错误:“System.Collections.Generic.IEnumerable”不包含“ToHashSet”的定义......问题是这个方法仅在 .Net 4.7.2 ( https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1?view=netframework-4.7.2 ) 我有.Net 4.6。可能在安装较新版本的 Visual Studio 时会自动安装较新的 .Net 版本,但我有 VS 2015。更新到最新的 .Net 版本(I 工具 4.8)后,这个问题就消失了。

于 2020-11-10T21:28:05.620 回答