The type or namespace name 'AddressableAssets' does not exist in the namespace

I am getting a compile error in my BuildCommand.cs but not in my HomeScreen.cs.

The type or namespace name ‘AddressableAssets’ does not exist in the namespace ‘UnityEngine’ (are you missing an assembly reference?)

Both BuildCommand.cs and HomeScreen.cs have this line:

using UnityEngine.AddressableAssets;

HomeScreen.cs compiles fine but BuildCommand.cs produces this error.

Why would it build in HomeScreen.cs but not BuildCommand.cs?!?!?!

I am on Addressables 1.16.19. I have tried regenerating and rebuilding my solution, and deleting the .vs folder.

Anybody? This is a pretty annoying thing to get stuck on.

I don’t really understand what BuildCommand.cs and HomeScreen.cs is, but question: do you use any assembly definition files? If you do, you need to add Addressables as reference to it. Also, BuildCommand sounds like an editor thing, are you sure both of them are UnityEngine.AddressableAssets?

Thanks, it’s CI code. I guess it must be be a different executable. How do I add the UnityEngine.AddressableAssets reference?

I found this asmdef:

{
    "name": "BEK.CI",
    "references": [],
    "optionalUnityReferences": [],
    "includePlatforms": [
        "Editor"
    ],
    "excludePlatforms": [],
    "allowUnsafeCode": false,
    "overrideReferences": false,
    "precompiledReferences": [],
    "autoReferenced": true,
    "defineConstraints": [],
    "versionDefines": []
}

I’m not really familiar with the CI things in Unity, never touched any of it. But IF it is the problem then you just need to replace this references, add this in your asmdef file:

    "references": [
        "Unity.Addressables"
    ],

Or if you edit it in the editor, then just add one line and choose it (the use guid option will replace it with the corresponding GUID):
7583668--940081--screenshot.png

Thank you, that fixed it. And now I know about asmdefs.

I don’t use assembly definitions so what I had to do to fix this is to “Regenerate project files” in Preferences > External Tools