This is expected behaviour - when compiling a build, Unity only includes those shaders that it knows are required (i.e. are assigned to a material in the scene). If you want to change a shader programmatically at runtime, Unity won't know to include that shader unless you explicitly tell it to.
To resolve this, go to Edit -> Project Settings -> Graphics and add the Toon/Basic Outlineshader to the list of Always Included Shaders.