Duplicate builds from the same C # source code on different machines

I'm trying to create a tool that is smart enough to programmatically examine executable versions of versions created by identical C # code, compiled on two separate machines at different times, and concluded that the code was identical when it could pick up any code changes, if present in C # code used to create these binaries.

I tried to use several approaches, but in order to keep this short, I will just stick to the last attempt. I run ildasm with the / text option in binaries and replace the GUIDs for anonymous fields, etc. In the text, but when the binaries come from different computers, I find that the text created using the ILDASM / text option is reordered. Binary files created from the same code, but compiled using the same settings on different machines, are also greatly reordered. Any suggestion on how to control this reordering of IL would be highly appreciated?

Greetings

PS: Any alternative strategies for doing this reliably are also welcome.

+6
source share
2 answers

I found that the solution is in accordance with what Eric Lippert mentioned in his post that his client decided to decide what could be achieved by setting the processor affinity for the compilation process before 01. After that, the executable / dlls are almost identical in excpetion to som mvid and used guids. Running ILDASM in these text-mode binaries and creating a simple hash tool to remove this random material provides such a solution. I simply provide this for the sake of completion and help others who may run into this problem.

+2
source

Waiting for Eric Lippert to wake up :) - wiki community from @mikez comment:

When the main developer (Eric Lippert) says in the compiler team, you should listen: http://ericlippert.com/2012/05/31/past-performance-is-no-guarantee-of-future-results/ contains a detailed explanation and Strong recommendation for not doing this (probably in response to this exact question):

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

Not.

+7
source

Source: https://habr.com/ru/post/919724/


All Articles