我正在使用Visual Studio 2019。
我有一个使用QT和QT VS Tools构建的c ++项目,该项目可以正常工作并且直到昨天为止。 我建立,推送到git并发布了最新版本,现在,今天, 似乎毫无理由地我的项目不再编译。
构建时开始出现以下错误:
Error MSB4096 The item "GeneratedFiles\Debug\moc_myqt.cpp" in item list "QtWork_ClCompile_Expanded" does not define a value for metadata "AdditionalIncludeDirectories". In order to use this metadata, either qualify it by specifying %(QtWork_ClCompile_Expanded.AdditionalIncludeDirectories), or ensure that all items in this list define a value for this metadata. Kreator C:\Users\Mars\AppData\Local\QtMsBuild\qt_globals.targets 389
没有git的更改,并且昨天在此状态下构建良好。
这是在命令行上运行MSBuild的日志:
D:\Source\TS2\tskreator>msbuild Kreator.sln
Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 23.5.2020. 17:49:08.
Project "D:\Source\TS2\tskreator\Kreator.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Win32".
Project "D:\Source\TS2\tskreator\Kreator.sln" (1) is building "D:\Source\TS2\tskreator\Kreator.vcxproj" (2) on node 1 (
default targets).
InitializeBuildStatus:
Touching "Debug\Kreator.tlog\unsuccessfulbuild".
Project "D:\Source\TS2\tskreator\Kreator.vcxproj" (2) is building "D:\Source\TS2\tskreator\Kreator.vcxproj" (2:2) on no
de 1 (Build target(s)).
InitializeBuildStatus:
Touching "Debug\Kreator.tlog\unsuccessfulbuild".
PreBuildEvent:
copy D:\Source\TS2\tskreator\binaries\msvc\Debug\*.* D:\Source\TS2\tskreator\Debug\
:VCEnd
D:\Source\TS2\tskreator\binaries\msvc\Debug\msvcp100d.dll
D:\Source\TS2\tskreator\binaries\msvc\Debug\msvcr100d.dll
D:\Source\TS2\tskreator\binaries\msvc\Debug\QtCored4.dll
D:\Source\TS2\tskreator\binaries\msvc\Debug\QtCored4.pdb
D:\Source\TS2\tskreator\binaries\msvc\Debug\QtGuid4.dll
D:\Source\TS2\tskreator\binaries\msvc\Debug\QtGuid4.pdb
D:\Source\TS2\tskreator\binaries\msvc\Debug\QtOpenGLd4.dll
D:\Source\TS2\tskreator\binaries\msvc\Debug\QtOpenGLd4.pdb
D:\Source\TS2\tskreator\binaries\msvc\Debug\vcruntime140.dll
9 file(s) copied.
CustomBuild:
All outputs are up-to-date.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtUicSetModified:
Skipping target "QtUicSetModified" because all output files are up-to-date with respect to the input files.
QtRccFilterSetModified:
Skipping target "QtRccFilterSetModified" because it has no outputs.
QtRccFilter:
Skipping target "QtRccFilter" because it has no outputs.
QtQmlSetModified:
Skipping target "QtQmlSetModified" because it has no outputs.
QtQml:
Skipping target "QtQml" because it has no outputs.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
QtMocSetModified:
Skipping target "QtMocSetModified" because all output files are up-to-date with respect to the input files.
C:\Users\Mars\AppData\Local\QtMsBuild\qt_globals.targets(389,5): error MSB4096: The item "GeneratedFiles\Debug\moc_myqt
.cpp" in item list "QtWork_ClCompile_Expanded" does not define a value for metadata "AdditionalIncludeDirectories". In
order to use this metadata, either qualify it by specifying %(QtWork_ClCompile_Expanded.AdditionalIncludeDirectories),
or ensure that all items in this list define a value for this metadata. [D:\Source\TS2\tskreator\Kreator.vcxproj]
Done Building Project "D:\Source\TS2\tskreator\Kreator.vcxproj" (Build target(s)) -- FAILED.
Done Building Project "D:\Source\TS2\tskreator\Kreator.vcxproj" (default targets) -- FAILED.
Done Building Project "D:\Source\TS2\tskreator\Kreator.sln" (default targets) -- FAILED.
Build FAILED.
"D:\Source\TS2\tskreator\Kreator.sln" (default target) (1) ->
"D:\Source\TS2\tskreator\Kreator.vcxproj" (default target) (2) ->
"D:\Source\TS2\tskreator\Kreator.vcxproj" (Build target) (2:2) ->
(QtWork target) ->
C:\Users\Mars\AppData\Local\QtMsBuild\qt_globals.targets(389,5): error MSB4096: The item "GeneratedFiles\Debug\moc_my
qt.cpp" in item list "QtWork_ClCompile_Expanded" does not define a value for metadata "AdditionalIncludeDirectories".
In order to use this metadata, either qualify it by specifying %(QtWork_ClCompile_Expanded.AdditionalIncludeDirectories
), or ensure that all items in this list define a value for this metadata. [D:\Source\TS2\tskreator\Kreator.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.16
我尝试清洁和重建,但没有帮助。
我尝试重新启动并将Visual Studio更新到最新版本。它没有帮助。
我尝试删除C:\ Users \ Mars \ AppData \ Local \ QtMsBuild,但没有帮助。
The node in the qt_global.target seems to have the AdditionalIncludeDirectories it is complaining about:
我的项目未使用预编译头。 我尝试添加设计时间日志,并且在%TEMP%文件夹中,设计时日志包含以下错误:
Initializing task factory "CodeTaskFactory" from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Build.Tasks.Core.dll".
Using "Expand" task from the task factory "Code Task Factory".
Task "Expand"
Done executing task "Expand".
C:\Users\Mars\AppData\Local\QtMsBuild\qt_globals.targets(389,5): error MSB4096: The item "GeneratedFiles\Debug\moc_myqt.cpp" in item list "QtWork_ClCompile_Expanded" does not define a value for metadata "AdditionalIncludeDirectories". In order to use this metadata, either qualify it by specifying %(QtWork_ClCompile_Expanded.AdditionalIncludeDirectories), or ensure that all items in this list define a value for this metadata.
Done building target "QtWork" in project "Kreator.vcxproj" -- FAILED.
在发布和调试中都会发生相同的错误。 我无法弄清楚问题是什么,并且谷歌搜索无法返回任何有用的信息。 您对做什么有建议?
您的项目文件需要重新创建,您没有提到重新创建它们。
首先,您可以通过查看git / github提交历史来确定对项目文件的更改,然后手动将丢失的更改应用回去。
Also easy way worth trying first (ex. by creating a blank new QT Project) and then in
VS Property manager -> C/C++ -> All options
: type "Force" and look what it says under "Force Include file". if there is anything copy to your original project.Qt最有可能自动生成项目文件的方式,因此您应该使用Qt项目生成器为源重新创建它们。
The
%(QtWork_ClCompile_Expanded.AdditionalIncludeDirectories)
is inserted into project file and it's not assigned a value. that's what it's causing error.