Errors building managed dll in 2021.2

I’m currently building dlls for Unity 2018.4 and 2019.4 and am trying to add 2021.2 but it seems like something has changed with UnityEditor.dll references. I’m getting this error even though I have a reference to UnityEditor.dll (C:\Program Files\Unity\Hub\Editor\2021.2.0f1\Editor\Data\Managed\UnityEditor.dll):

Error CS0246 The type or namespace name ‘EditorWindow’ could not be found (are you missing a using directive or an assembly reference?)

Weirdly if I click on the error in Visual Studio it opens the file and immediately finds the reference and the error disappears!

I’ve tried referencing the UnityEditor.CoreModule.dll, the UnityEditor.UI.dll in ScriptAssemblies etc.

What am I missing?!

Looks like the UnityEditor.dll (2021.2) uses .NET 4.
previous versions use .NET 2
So the framework “Unity 3.5 .net” from Visual Studio is not compatible :face_with_spiral_eyes:

I can build the editor DLL with .net 4.7.1, but it doesn’t work in Unity…

EDIT : Now it works (bad path in my project :stuck_out_tongue: )
So switching to .NET 4.7.1 fix it.