MessagePack-CSharp requires System.Runtime.CompilerServices.Unsafe 4.5.1
Unity.Burst and Unity.Collections require 4.5.0
This causes Unity to go cause havoc:
- Breaks all assembly definitions
- Causes Unity to Crash
- Unable to import the dlls anymore
- Unable to show the inspector for any
Unity.2019.3.0f5
Having the following asmdef in my project
{
"name": "Plugins",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": true,
"precompiledReferences": [
"Zenject-usage.dll",
"Sirenix.OdinInspector.Attributes.dll",
"Sirenix.Utilities.dll",
"Sirenix.Serialization.Config.dll",
"Accord.dll",
"Accord.Math.dll",
"Accord.Math.Core.dll",
"Sirenix.Serialization.dll",
"System.Memory.dll",
"System.Threading.Tasks.Extensions.dll",
"System.Buffers.dll",
"System.Runtime.CompilerServices.Unsafe.dll",
"Ookii.Dialogs.dll",
"System.Windows.Forms.dll"
],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
whcih references a “non auto reference” to System.Runtime.CompilerServices.Unsafe.dll and updating packages from
{
"dependencies": {
"com.unity.burst": "1.2.0",
"com.unity.collections": "0.5.0-preview.9",
"com.unity.entities": "0.5.0-preview.17",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.1.4",
"com.unity.inputsystem": "1.0.0-preview.3",
"com.unity.jobs": "0.2.3-preview.9",
"com.unity.mathematics": "1.1.0",
"com.unity.memoryprofiler": "0.2.0-preview.1",
"com.unity.performance.profile-analyzer": "0.5.0-preview.1",
"com.unity.physics": "0.2.5-preview.1",
"com.unity.quicksearch": "1.4.1",
"com.unity.rendering.hybrid": "0.3.2-preview.17",
"com.unity.searcher": "4.0.9",
"com.unity.test-framework.performance": "1.3.2-preview",
"com.unity.testtools.codecoverage": "0.2.2-preview",
"com.unity.textmeshpro": "2.0.1",
"nuget.mono-cecil": "0.1.6-preview",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.xr": "1.0.0"
},
"testables": [
"com.unity.test-framework.performance"
]
}
to
{
"dependencies": {
"com.unity.burst": "1.2.1",
"com.unity.collections": "0.5.0-preview.9",
"com.unity.entities": "0.5.0-preview.17",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.1.4",
"com.unity.inputsystem": "1.0.0-preview.4",
"com.unity.jobs": "0.2.3-preview.9",
"com.unity.mathematics": "1.1.0",
"com.unity.memoryprofiler": "0.2.0-preview.1",
"com.unity.performance.profile-analyzer": "0.5.0-preview.1",
"com.unity.physics": "0.2.5-preview.1",
"com.unity.rendering.hybrid": "0.3.2-preview.17",
"com.unity.searcher": "4.0.9",
"com.unity.test-framework.performance": "1.3.2-preview",
"com.unity.testtools.codecoverage": "0.2.2-preview",
"com.unity.textmeshpro": "2.0.1",
"nuget.mono-cecil": "0.1.6-preview",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.xr": "1.0.0"
},
"testables": [
"com.unity.test-framework.performance"
]
}
breaks Unity completly and it does not recover. As there is no way to control the dlls added via packages I am not able to remove the namespace clash as Unity will add it’s own version via Burst and that causes Unity to break horribly. All that would be needed is to make sure packages use their own dll and don’t auto import them into any other asmdef in the whole unity project.
This currently means I am not able to add anything to a Unity project which requires a different version of a dll that is added via Unity packages.
Furthermore unity does do the following extremly nasty things:
-
Create new asmdef files, which removes ALL the dependencies you would require to compile the code within this asmdef, which causes the asmdef to not compile anyway
-
Fallback to Assembly-CSharp.csproj, … default projects although it is clear that those also can never compile as all the dependencies and folders are set up as defined in the asmdef files and therefore this breaks
-
Crashes regularly once this happens. The only way to get Unity into a non crashing state is to close unity, manually edit all asmdef, delete all the dlls involved from all package cache folders, then remove the dll you would need and import from your code and then once there is no such nameclash anymore then start Unity again and reimport everything.
-
Auto reference added dlls from within a package (Burst) to outside of that package (e.g. ANY other csproj)
Workaround
-
Remove the dll you have added from your project and fallback to the package manager version
-
Warning: This workaround will break the second your code actually would need two different versions of the dll!
See also
