How to set 'Use pre-built Engine" from script (buildpipeline)?

I cannot figure out how to set/unset Use pre-built Engine from script. When this option is set, the build process throws an exception:

Exception: 'Pre-built engine' option is not supported for WebAssembly. In order to build disable 'Use pre-built Engine' or enable Asm.js linker target in Player Settings.

This is the code so far:

[MenuItem("Build/WebAssembly only &w")]
public static void BuildWebAssemblyOnly()
  // collect open scenes in hierarchie
  var c = SceneManager.sceneCount;
  var scenes = new string
      for(var i = 0; i<c; i++)
        scenes* = SceneManager.GetSceneAt(i).path;

      // backup player settings
      var linkerTarget = PlayerSettings.WebGL.linkerTarget; 
      var nameHashes   = PlayerSettings.WebGL.nameFilesAsHashes = true;
      var splashShow   =;
      // settings for current build process
      PlayerSettings.WebGL.linkerTarget             = WebGLLinkerTarget.Wasm;
      PlayerSettings.WebGL.nameFilesAsHashes        = true;              = false;
      // build
      var buildOptions = BuildOptions.AllowDebugging | BuildOptions.Development | BuildOptions.StrictMode;
      BuildPipeline.BuildPlayer(scenes, targetPath, BuildTarget.WebGL, buildOptions);
      // restore player settings
      PlayerSettings.WebGL.linkerTarget             = linkerTarget;
      PlayerSettings.WebGL.nameFilesAsHashes        = nameHashes;              = splashShow;

I dislike having to set this option manually. Is there any way to ensure by script, this option is turned off for the build process?

you can get/set ‘Pre-built engine’ option via EditorUserBuildSettings.webGLUsePreBuiltUnityEngine:

EditorUserBuildSettings.webGLUsePreBuiltUnityEngine = false;