title: How can I force a the build process to fail through a Unity editor script?
body: <p>I want to force the build process to fail if some validation conditions are not met.</p>
  
  <p>I've tried using an <code>IPreprocessBuildWithReport</code> with no success:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using UnityEditor.Build;
  using UnityEditor.Build.Reporting;
  
  public class BuildProcessor : IPreprocessBuildWithReport
  {
      public int callbackOrder =&gt; 0;
  
      public void OnPreprocessBuild(BuildReport report)
      {
          // Attempt 1
          // Does not compile because the 'BuildSummary.result' is read only
          report.summary.result = BuildResult.Failed;
  
          // Attempt 2
          // Causes a log in the Unity editor, but the build still succeeds
          throw new BuildFailedException("Forced fail");
      }
  }
  </code></pre>
  
  <p>Is there any way to programmatically force the build process to fail?</p>
  
  <p>I'm using Unity 2018.3.8f1.</p>