How to solve "The type or namespace name 'MenuItemAttribute' could not be found"?

I am new to Unity. I am working on a Unity project, and i used to be able to create prefabs and bundle them.

I guess at some point I have changed something, because I can no longer build bundles.

All answers to this question that I found were saying that I need to put my scripts under Assets/Editor, but that already is the case. And what is more interesting is that the script can’t find a reference to that type, depending on what action I put inside the function. I don’t know what is the relation there.

So I have this editor command defined like this:

I was able to narrow it down to this - if I use the DisplayDialog which gets generated by Visual Studio by default, everything works fine.

But if I uncommend the BuildAssetBundles line and comment out the dialog one, I get this:

This doesn’t make sense to me since both times the function seems to make use of the MenuItem.

Woah! It took me hours to find this. Every answer I found initially was saying to create an Editor folder, while in fact what I needed to do was to create a new asmref inside the folder that contains the editor scripts.

There is more info here:

Solution: go to unity, go to the respective folder, and create a new assembly definition.