How do I solve a BuildAssetBundles Compilation Error that only occurs in the Editor?

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;

/// <summary>
/// Builds the asset bundle
/// Code below is based on the Unity Scripting Reference documentation for the
/// BuildPipeline BuildAssetBundles method
/// </summary>
public class BuildAssetBundle : MonoBehaviour {

    /// <summary> 
    /// Adds a menu item to build the asset bundle
    /// </summary>
    [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 error messages in the Console pane that say

The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?
Error building Player because scripts had compiler errors

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

Thanks in advance for any suggestions.

I’m a n00b. This was my first editor script and I didn’t realize that editor scripts have to live in a special Editor folder. The problem is resolved.