modesttree / Zenject

Dependency Injection Framework for Unity3D
MIT License
2.54k stars 273 forks source link

Reflection baking error with built-in Unity package #33

Open brookman opened 5 years ago

brookman commented 5 years ago

After upgrading to Unity 2019.2 there is a built-in package for the Jetbrains Rider IDE. This package produces an error in the reflection baking while building:

ArgumentException: Invalid path
System.IO.Path.GetDirectoryName (System.String path) (at <a8ed250850854b439cedc18931a314fe>:0)
Zenject.ReflectionBaking.UnityAssemblyResolver..ctor () (at Assets/Plugins/Zenject/OptionalExtras/ReflectionBaking/Unity/UnityAssemblyResolver.cs:34)
Zenject.ReflectionBaking.ReflectionBakingBuildObserver.TryWeaveAssembly (System.String assemblyAssetPath) (at Assets/Plugins/Zenject/OptionalExtras/ReflectionBaking/Unity/ReflectionBakingBuildObserver.cs:65)
Zenject.ReflectionBaking.ReflectionBakingBuildObserver.OnAssemblyCompiled (System.String assemblyAssetPath, UnityEditor.Compilation.CompilerMessage[] messages) (at Assets/Plugins/Zenject/OptionalExtras/ReflectionBaking/Unity/ReflectionBakingBuildObserver.cs:37)
UnityEditor.Compilation.CompilationPipeline.<SubscribeToEvents>m__3 (System.String assemblyPath, UnityEditor.Compilation.CompilerMessage[] messages) (at C:/buildslave/unity/build/Editor/Mono/Scripting/ScriptCompilation/CompilationPipeline.cs:179)
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)

The problem is that assemblies[i].Location returns an empty string. I am not sure if this is a problem with the package or with Zenject. But the Rider package is editor only so it should probably not be included in the reflection baking process.

Unity: 2019.2.5f Extenject/Zenject: 9.0.0 Workaround: In UnityAssemblyResolver.cs add a Try-Catch around AddSearchDirectory(Path.GetDirectoryName(assemblies[i].Location));

albermotion commented 4 years ago

Same error with 2019.3.9f1. It gives 30 ArgumentException: Invalid path errors