deniszykov/t4-templates-unity3d

T4 can't process templates when some GAC assembly embedded directly into project

dmitry1100 opened this issue · 3 comments

I have a project with an asset PrefabPlace'N'Bake from 3Dynamite. It causes T4 to fail on processing templates saying System.Windows.Forms referenced multiple times. I made some debugging and found that PrefabPlace'N'Bake relays on in-project System.WindowsForms.dll and when T4 builds references list it includes one from GAC (MonoBleedingEdge) and one from PrefabPlace'N'Bake. I can't share whole PrefabPlace'N'Bake but I reproduced the issue in the following way. I created empty project with Unity 2018 or 2019 with T4 installed. Copy "....\Editor\Data\MonoBleedingEdge\lib\mono\2.0-api\System.Windows.Forms.dll" into Editor folder of the project. Write some code that references System.Windows.Forms. So, this breaks T4 generator. I'd like to note that copying System.Windows.Forms.dll from 4.5 does not break the generator. It seems .NET API version of DLL must be not the same as GAC's one to reproduce the issue. Here I attached a project that has an issue (I think it is Windows only because Forms is not available on macOS).
MultipleReferencesBugT4.zip
I thought how it can be managed and I think maybe it would be great if T4 have some kind of global generation settings accessible via Edit > Project Settings (can be implemented throug [SettingsProvider] for example). So, those settings could have some kind of exclusion paths like don't take into account assemblies in some directories or maybe direct DLL paths.

Hi, @C0DEF52!

Thanks for error report! And thanks for the suggestion.

I think I will do additional settings in the next release (one or two weeks).

It has been fixed in v1.0.14. Soon on Unity Asset Store.
Or dll could be updated from this repo.

It has been fixed in v1.0.14. Soon on Unity Asset Store.
Or dll could be updated from this repo.

Thank you for the fix!