Execute code on Build only

how can I Execute a line of C# code only on Standalone Build
I tried

Debug.Log("On Build");

But still on console “On Build” gets printed.

You can use preprocessor defines like normal boolean operations. So to have “On Build” get printed only in your standalone build and not in the editor simply check for UNITY_EDITOR like this:

Debug.Log("Do Build");