The easiest way to achieve this is to create separate build configurations for each environment in which you must publish. You can clone your new build configurations from Release. Then, in the project settings, enter the name of your assembly configuration in the conditional compilation symbol field.
So, for example, we have a Stage assembly configuration that is identical to Release, except that it defines the STAGE compiler constant. Then in the code you can use the #if (STAGE) checks.
source share