1

Give a source .cs file as simple as below, is there any way to produce identical .dlls with MSBuild (or at least with csc.exe), so their binary hash would match?

foo.cs

public class Foo
{
    public int Bar;
}

foo.bat

del foo*.dll

csc /t:library foo.cs
move foo.dll foo1.dll

csc /t:library foo.cs
move foo.dll foo2.dll

powershell -Command "Get-ChildItem foo*.dll | ForEach-Object { $_.CreationTime = $_.LastWriteTime = $_.LastAccessTime = \"2013-03-15\" }"

Sample binary diff report is at https://dl.dropbox.com/u/65419748/CscBin.html

Does anyone know what those differences are and how to get around them?

Jeffrey Hantin
  • 35,734
  • 7
  • 75
  • 94
Ilya Kozhevnikov
  • 10,242
  • 4
  • 40
  • 70
  • Yeah @JonSkeet - there's no way that I'm aware of to generate identical compiled output between subsequent compilations - it's geared to *always* generate unique output, otherwise you'd never know you recompiled it. – JerKimball Mar 15 '13 at 16:22
  • Thanks. So given binary hash is not an option and creation/lastmodified stamps are unreliable, how would one compare project artefacts in general and dlls specifically without access to source control history? – Ilya Kozhevnikov Mar 15 '13 at 16:38
  • @IlyaKozhevnikov: I generally wouldn't try to. This is presumably part of some bigger requirement - so post that bigger requirement as a new question, understanding that comparing the binaries isn't a good solution. – Jon Skeet Mar 15 '13 at 17:06

0 Answers0