8

We recently had a developer leave our organization. We're not sure if the version of an executable he put on a production server is the same that is currently in TFS. Is there any way (besides using something like Just Compile or ILDASM) to build the project from TFS and compare that executable to the one currently on our production server?

UPDATE: I'm trying out Just Decompile, and I've loaded both binaries, so I'm stepping through each namespace, member, etc to compare them against each other. I'm used to using Schema Compare in Visual Studio to compare the schemas of 2 databases and seeing the updated, removed and added items with the differences highlighted. Isn't there some tool that would take these 2 decompiled binaries and somehow highlight the differences?

Christopher Garcia
  • 2,536
  • 7
  • 30
  • 40
  • Are you asking for a way in TFS to compare and then build? – Mr. Mr. Jul 09 '12 at 23:11
  • No, I have a project in TFS, and I have an executable built from that project from some time ago. I need to see if the version I build from TFS is the same as the compiled version that is already in production. – Christopher Garcia Jul 09 '12 at 23:13
  • There is a plugin called File Disassembler for Reflector that can decompile a whole assembly to its source code. You could do that for both compiled assemblies and do a textual diff of the outputs. Alternatively, if your code in TFS should be the code deployed to the production server, just deploy it again. – adrianbanks Jul 09 '12 at 23:16
  • 1
    Possible [duplicate](http://stackoverflow.com/questions/1296590/how-to-compare-two-exe-files-one-built-from-the-old-code-now-and-the-existing-ex) – Nathan Jul 09 '12 at 23:17
  • @Nathan Think you are correct, but unsure if the accepted answer will definitely work to hash both assemblies, I thought of that approach but as you cannot guarantee the assembly will compile the same every time...... – Mr. Mr. Jul 09 '12 at 23:42
  • Two c# assemblies will almost certainly not compile the same every time. – Denise Skidmore Jun 25 '15 at 20:50

3 Answers3

6

Right now I can only think of this approach:

  1. Use dotPeek to decompile the live assembly
  2. Use dotPeek to decompile the same assembly freshly built from TFS
  3. Use a tool like Beyond Compare on the two decompiled sources
  4. Merge the changes as necessary

Hope this is what you were looking for??

Other reading that may be beneficial for the future in terms of versioning so you know what dll contains what functionality (may or may not be useful for you, forgive me if I am telling you something obvious):

Best practices/guidance for maintaining assembly version numbers

Good luck

Community
  • 1
  • 1
Mr. Mr.
  • 4,257
  • 3
  • 27
  • 42
5

Yes using NDepend you can diff between two .Net assemblies. Although even compiling exactly the same source twice will not generate exactly the same assemblies.

softveda
  • 10,858
  • 6
  • 42
  • 50
  • 1
    Perhaps you should explain why the same source can generate different assemblies. – Kendall Frey Jul 09 '12 at 23:19
  • 4
    Eric Lippert has explained this in detail on his blog. http://blogs.msdn.com/b/ericlippert/archive/2012/05/31/past-performance-is-no-guarantee-of-future-results.aspx – softveda Jul 09 '12 at 23:28
  • 2
    I just used NDepend and opened 2 versions of the binary in question in it. In the generated code diff report, it shows no differences, so I'm going to use it to compare 2 known different assemblies to make sure that it does indeed pick up the differences. That way I know I can trust the output. – Christopher Garcia Jul 11 '12 at 14:19
  • This is unreliable I don't recommend it I wasn't able to get it to show me REAL DIFFERENCE between code... – Daniel Kmak Dec 28 '15 at 13:38
  • @DanielKmak please come back to us, we have thousands of users that actually use this feature with success, see related documentation here http://www.ndepend.com/docs/code-diff-in-visual-studio – Patrick from NDepend team Jun 12 '17 at 15:07
-1

A product we use for detailed comparisons, including comparisons of binary files, is Beyond Compare. When we first got the product I thought it would be something of limited utility, but it has helped us solve some very tricky problems. It compares directories, text files, binary files, mp3's, pictures, and software versions. It's not particular expensive either.

I just ran the product against the binaries of an application in both Release and Debug and it highlighted every diff.

I am sure that you could run ILDASM against two binaries and do an eyeball comparison, but a tool like this will probably pay for itself over and over again.

Cyberherbalist
  • 12,061
  • 17
  • 83
  • 121
  • 1
    +1 for Beyond Compare, I use it for all my commits it is truly brilliant. – Mr. Mr. Jul 09 '12 at 23:18
  • Two c# assemblies will certainly be different, Beyond compare won't help you find out if the differences in a binary file are meaningful. – Denise Skidmore Jun 25 '15 at 20:53
  • Why not, @DeniseSkidmore? Maybe not always, but you don't need to be able to understand binary as a native language to benefit from a binary comparison. Like I said, it has proven useful to me to be able to see the extent of binary differences. It is a fact that text strings do appear in binaries, for instance. – Cyberherbalist Jun 25 '15 at 22:33
  • It requires knowledge of the structure of the binary file before binary compare is useful. – Denise Skidmore Jun 26 '15 at 18:14
  • @DeniseSkidmore I have found binary compare occasionally useful without knowing the first thing about the structure of the binary file. Your saying it's not ever useful contradicts my experience, and guess what? My experience trumps your opinion. At least for me. Have a nice day! And thanks ever so much for the reputation hit. You're so sweet. – Cyberherbalist Jun 29 '15 at 16:22