Description
In the Nerdbank.GitVersioning.Tasks.CompareFiles class, the IsContentOfFilesTheSame method calls Stream.Read and assumes that a return value smaller than requested means that it got to the end of the file. As mentioned in #797 (comment), such an assumption is generally a bug. Here though, the stream refers to a regular file, which makes the assumption more likely to hold.
Nerdbank.GitVersioning/src/Nerdbank.GitVersioning.Tasks/CompareFiles.cs
Lines 127 to 133 in 719b0d5
The CompareFiles task is used in Nerdbank.GitVersioning.targets, for deciding whether to run the Copy task. The bug might cause the task to consider the files different when they are actually identical; the target would then needlessly copy the file and cause MSBuild to execute other targets, resulting in a slower incremental build but eventually the correct artefacts.
It might be possible to delete the CompareFiles task altogether and use the SkipUnchangedFiles parameter of the Copy task instead.