VS: 16.4.0 warns on CustomBuild that does not create all outputs
We are using Visual Studio 16 generator, and then we try to build INSTALL.vcxproj using msbuild. However with 16.4.0 (which is in early previews) we're getting a warning like this one:
(CustomBuild target) -> C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(230,5): warning MSB8065: Custom build for item "E:\repos\corefx\artifacts\obj\native\netcoreapp-Windows_NT-Debug-x64\CMakeFiles\6588b57184d8ccf55ab7eca0b7ac55b9\INSTALL_force.rule" succeeded, but specified output "e:\repos\corefx\artifacts\obj\na tive\netcoreapp-windows_nt-debug-x64\cmakefiles\install_force" has not been created. This may cause incremental build to work incorrectly. [E:\repos\corefx\artifacts\obj\native\netcoreapp-Windows_NT-Debug-x64\install.vcxproj]
I did a little investigation by cracking opening the Build Tasks dll that Visual Studio uses to execute custom commands and it seems like they now do validation that after executing the command the output file specified as part of the custom command exists, if it doesn't exist, it logs that warning. This seems like an issue with the CustomBuild as it is not doing anything, it is just running cd .
as part of the command, of course no file will be creates as an output. This is the CustomBuild
item definition I see in my produced vcxproj.
<CustomBuild Include="E:\repos\corefx\artifacts\obj\native\netcoreapp-Windows_NT-Debug-x86\CMakeFiles\4696b813a8447feb4893b87d575ddcd6\INSTALL_force.rule">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> </Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
cd .
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">E:\repos\corefx\artifacts\obj\native\netcoreapp-Windows_NT-Debug-x86\CMakeFiles\INSTALL_force</Outputs>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> </Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">setlocal
cd .
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">E:\repos\corefx\artifacts\obj\native\netcoreapp-Windows_NT-Debug-x86\CMakeFiles\INSTALL_force</Outputs>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
<Message Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'"> </Message>
<Command Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">setlocal
cd .
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">E:\repos\corefx\artifacts\obj\native\netcoreapp-Windows_NT-Debug-x86\CMakeFiles\INSTALL_force</Outputs>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">false</LinkObjects>
<Message Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'"> </Message>
<Command Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">setlocal
cd .
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">E:\repos\corefx\artifacts\obj\native\netcoreapp-Windows_NT-Debug-x86\CMakeFiles\INSTALL_force</Outputs>
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">false</LinkObjects>
</CustomBuild>
Any suggestions?
We of course, could use
cmake --build <dir>
cmake --install <dir>
after generating the build tree, but I don't know if it is worth the change, since we somehow rely on VS.
/cc @brad.king