BuildAssetBundles Compilation Error in Editor Only

Greetings,

I’m running Unity 5.5.0f3 personal on Windows 10, 64 bit, and I’m trying to build an AssetBundle for a simple project. Here’s the script I derived from the BuildPipeline BuildAssetBundles documentation:

using UnityEngine;
using UnityEditor;

///


/// Builds the asset bundle
/// Code below is based on the Unity Scripting Reference documentation for the
/// BuildPipeline BuildAssetBundles method
///

public class BuildAssetBundle : MonoBehaviour {

///


/// Adds a menu item to build the asset bundle
///

[MenuItem(“Asset Bundle/Build Asset Bundle”)]
static void BuildAB() {

// Put the bundle in a folder called “AssetBundle”
BuildPipeline.BuildAssetBundles(“Assets/AssetBundle”,
BuildAssetBundleOptions.None,
BuildTarget.StandaloneWindows);
}
}

This code compiles fine in Visual Studio with no errors (and I’ve confirmed there’s an assembly reference to the UnityEditor dll in the Visual Studio project).

When I select Asset Bundle > Build Asset Bundle from the menu bar in the Unity editor, I get an error message in the Console pane that says

The type or namespace name `UnityEditor’ could not be found. Are you missing an assembly reference?

Any ideas how I can fix this so I can build my Asset Bundle in the editor?

Thanks in advance for any suggestions.

edit: Sorry, I should have mentioned that the Console pane also has a second error message that says

Error building Player because scripts had compiler errors

I am getting a similar issue in Unity 5.6.0f3, except that for me it is UnityPurchasing that cannot be found when building AssetBundles on iOS. It works on my colleagues’ machines.