1

I have a project with a few conditional builds. I compiled it. And then used dotpeek to look at it. I noticed ALL conditional statements and the code that it wraps even when not defined.

Since this app is modified in some key ways for different clients, I would like a build for that client have a binary that ONLY contains the active #ifs that have been defined.

How can I do an automated build that achieves this?

Joe
  • 721
  • 9
  • 22
  • 2
    Please share some small code with conditional statements that DotPeek is able to recover from the compiled binary, which can be reproduced on our side. – Dmitry Aug 22 '17 at 21:50

1 Answers1

3

dotPeek does 2 things

  1. it can decompile IL code
  2. it can read the PDB file and look up the source file

You can see this in the context menu. One entry is "Decompiled sources" and the other is "Sources from symbol files":

Context menu

By double clicking an item, it will first try to perform action 2, which is: show the source file that exists on your hard disk.

Here you see a very simple program:

  • left: Sources from symbol files
  • middle: Decompiled sources
  • right: IL code

As you can see, the compiled code only contains those parts which it was compiled for.

Comparison

Therefore, there's no need to strip those parts in a build script, because the DLL or EXE does not contain it.

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222