I'm a little confused about compatibilities between netstandard
, netframework
, netX
and how mono fits into the picture...
I understand that Rider's T4 engine runs on mono, but does that mean I can't use net5.0
assemblies in my T4 templates?
Currently, I have a net5.0
project, referencing net5.0
nuget assemblies.
In my T4 templates, I'm referencing the assembly DLLs in bin/Debug/net5.0
with `<@ assembly name="...">
When I run the T4 templates in-proc in a net5.0
Console Application via Mono.TextTemplating.TemplateGenerator.TemplateGenerator
, then the templates work.
However, if I right-click a template in the Solution explorer and select 'Run Template', I get a list of errors that core System.* libs are missing, e.g.
Generate.tt(21, 25): [CS0012] The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Is this a bug in Rider?
Due to implementation details, Rider compiles T4 files targeting a version of .NET Framework, that's why it has problems with files referencing net5.0
assemblies. As far as I understand what I see in Mono.TextTemplating
, they target the runtime they are launched in instead. To solve your problem I'd suggest trying Mono.TextTemplating
as a command-line tool - it might be able to compile files with net5.0
references. To integrate that external tool into Rider, you can go to File > Settings > Tools > Custom Tools
, disable Bundled T4 Template Executor
and add a custom tool for Mono.TextTemplating
CLT.
To answer your question: yes, it probably can be called a bug