Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeatable builds from same C# source code on different machines

I am trying to produce a tool which is smart enough to programmtically examine release version binaries produced by identical C# code compiled on two seperate machinces at different times and conclude that the code was identical while being able to pick up any code changes if present in the c# code used to produce these binaries.

I have tried using a number of approaches but in order to keep this short i'll just stick to the latest attempt. I run ildasm with the /text option on the binaries and replace the GUIDs for anonymous fields etc in text, but when the binaries come from different pcs i find that the text produced by ILDASM /text option is reordered. The binaries originating from the same code but compiled by same setup on different machines also appear heavily reordered. Any suggestion how one may be able to control this reordering of IL would be much appreciated ?

Cheers

PS: Any alternative strategies of reliably accomplishing this are also most welcome.

like image 622
Comic Book Guy Avatar asked Jul 05 '12 06:07

Comic Book Guy


1 Answers

Waiting for Eric Lippert to wake up :) - community wiki out of @mikez 's comment:

When a principal developer (Eric Lippert) on the compiler team speaks, you should listen: http://ericlippert.com/2012/05/31/past-performance-is-no-guarantee-of-future-results/ contains detailed explanation and strong recommendation for not doing it (likely in response to this precise question):

Is compiling the same C# program twice guaranteed to produce the same binary output?

No.

like image 90
3 revs, 3 users 88% Avatar answered Sep 18 '22 00:09

3 revs, 3 users 88%