VS: Fix unnecessary rebuild of C# projects due to ZERO_CHECK reference
This fixes an issue we had for a mixed C#/native project in VS2017: The C# target was always rebuilt and switching MSBuild output verbosity to Diagnostic produced the following reason:
Project '<name>' is not up to date. CopyLocal reference '<path-to-CMAKE_BINARY_DIR>\Debug\ZERO_CHECK' is missing from output location.
ReferenceOutputAssemply to true stops the rebuild but will produces a warning in Visual Studio noting that ZERO_CHECK cannot be referenced as it does not have a 'dll' or 'exe' extension. Some digging suggested that (see e.g. this MSDN article) setting
Private to false (which changes the "Copy Local" option to false) could fix the error. It does - but only half way: Every second time the project was checked a rebuild was still triggered. MSBuild gives the following reason:
Project '<name>' is not up to date. Last build was with unsaved files.
It turns out that setting
CopyToOutputDirectory to "Never" in the ProjectReference does the trick. I am not totally sure why but it seems that for projects references that have
ReferenceOutputAssemply setting it to false it should not do any harm?!