1

Until now, I compiled my project from VS and now I moved compilation process to a script. I use vcbuild.exe with command line parameters for this purpose. What I see is that my output files is not bytewise similar at all. I compared a command line from VS and from my script and it's identical down to the last comma, so I really don't understand why it's so different.

Command line identical from VS compilation and from vcbuild log (line breaks added for clarity):

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe
    /noconfig
    /unsafe-
    /nowarn:1701,1702
    /platform:x86
    /errorreport:prompt
    /define:TRACE
    /reference:C:\blahblah.dll
    /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
    /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
    /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll
    /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
    /debug:pdbonly
    /optimize+
    /out:obj\x86\Release\blah.exe
    /target:winexe
    /win32icon:blah.ico
    ..\..\blah\version.cs
    Program.cs
    Properties\AssemblyInfo.cs
Jeffrey Hantin
  • 35,734
  • 7
  • 75
  • 94
user1766151
  • 86
  • 1
  • 4

1 Answers1

0

I'm guessing that you by "binary compatible" mean that your files aren't exactly the same, not that they won't execute in the same way depending on how you invoke the compiler.

The compiler (Csc.exe) adds a timestamp and some other stuff into each compiled file so even if the source is unchanged the files generated from two different compilations won't be an exact match. There is a thread about it here on SO that explains it a bit, Why does C# generate different EXEs for the same source-code?, but I've also read a good blog post on MSDN that talked about this but I can't seem to find it right now.

Community
  • 1
  • 1
Karl-Johan Sjögren
  • 16,544
  • 7
  • 59
  • 68
  • 1
    I'm guessing you are looking for this post: http://blogs.msdn.com/b/ericlippert/archive/2012/05/31/past-performance-is-no-guarantee-of-future-results.aspx – vossad01 Oct 22 '12 at 19:30
  • I know about a little difference cause of time stamp, but I have two files what have the same size and work perfectly, but on binary(hex) comparing it's completely different. – user1766151 Oct 23 '12 at 09:28
  • Well as Eric Lippert says in the link @vossad01 found for me, "Any given C# program has infinitely many equivalent MSIL programs;" so I'm guessing there is more that happens under the hood that might result in slightly different IL and thus a different binary file when compiled to an executable. – Karl-Johan Sjögren Oct 23 '12 at 18:53