Monodevelop error after Unity 5.1 upgrade: An item with the same key has already been added.

I’ve just upgraded my project to Unity 5.1, and now monodevelop fails to build the project with the following error:

An item with the same key has already been added. (Error: System.ArgumentException) (Assembly-UnityScript)

I have lots of plugins (Standard Assets, iOSNative, ImageEffects among others), and can see no way of finding out where the problem is.

Anyone know how to narrow down where the problem might lie?

It looks like the error may be caused by DEBUG and TRACE occurring twice in the DefineConstants section of the Unity project files (i.e., .csproj and .unityproj files).

I filed a bug (703149) on this. Unfortunately, it’s even simpler (although I found it with my 5.0.2 project when I opened it in 5.1). I made a new project in 5.1, and added a UnityScript .js file. Compiles fine in the Editor, but if you try to compile it in MonoDevelop (I’m on a Mac), you get the error. My personal theory is that the duplicate item(s) in question are the DEBUG and TRACE defines, as looking at the Application Output: Errors (click “Errors” at bottom right of MonoDevelop window), you see that they are in there twice, whereas if you compile in 5.0.x they are only there once. The 5.1 release notes mention those as having been touched in 5.1. But my guess could be incorrect.

While I can still debug with MonoDevelop, building in MonoDevelop gives that error and then won’t try to compile the rest.

Had the same error. Just changed the build type from debug to release. It worked.

I have had this issue in the past and simply had to remove an extra assembly reference in Mono. I unfortunately do not recall the name, but it is typically the last assembly reference in the solution. Sorry I am not able to remember to name.

I had the same error. I tried changing the references, deleting some, etc. It didn’t work. I just changed the build from debug to release. And no more error.

I had the same error. It’s happening in 5.1.0 but It’s OK on 5.0.2.
I’ll try to upgrade just to 5.0.3, but it’d be great if we can find the root issue.

I am having the same issue. Removing the two parametes (DEBUG and TRACE) from the project options did not fix it for me. It fixes it temporarily, but the parameters get added again when I open Mono/Unity next time.