Details
Description
For MSVS2017, when adding a class or filename with the name "Debug", for example for "DebugTest.cpp", typically the following XML is generated in the .vcxproj:
<ClCompile Include="GeneratedFiles\Debug\moc_DebugTest.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="GeneratedFiles\Release\moc_DebugTest.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> </ClCompile>
The first time, when the file has just been added, this is what is added.
However, when editing DebugTest.cpp and saving, the 'Release' XML is replaced with:
<ClCompile Include="GeneratedFiles\Release\moc_DebugTest.cpp" />
Thus removing the ExcludedFromBuild tag, and will now cause Debug builds to fail compilation as both the Debug and Release moc_DebugTest.cpp will be compiled:
1>DebugTest.cpp
1>moc_DebugTest.cpp
1>moc_DebugTest.cpp
1>c1xx : fatal error C1083: Cannot open source file: 'GeneratedFiles\Release\moc_DebugTest.cpp': No such file or directory.
This only happens if the filename has the keyword "Debug" in it.