We're currently migrating a project from .NET Framework to .NET Core 3.1 and we have a problem getting some of our T4 templates to work. These templates import one or more assemblies from our solution in order to generate code using reflection. The assemblies are .NET Core 3.1 libraries. The issue seems to be that the T4 engine in Visual Studio 2019 is running on Framework and is unable to load the Core assemblies properly.
When running the templates, I'm getting a ReflectionTypeLoadException
. After inspection of the exception, it becomes clear that the T4 engine can't find System.Runtime
. There is some workaround for that (here), but when I apply that, that just moves the problem to the next dependency, which is a NuGet package. So the workaround doesn't work.
Is there any way to make T4 templates work with .NET Core 3.1 assemblies? Or is there any similar alternative to T4 templates that works with .NET Core 3.1?
CodeClass
,CodeProperty
,CodeType
,CodeInterface
, .... It would be an expensive change though. – Hornet