According to the latest comments in this thread, .tt templates will now after all be supported in ASP.NET 5 starting with Visual Studio Update 1.
Which IMHO would be great because after using T4MVC for years, I certainly don't wanna go back to using magic strings for route/view names (error prone and not refactoring-friendly).
However, I can't quite get it to work with ASP.NET 5 RC and Visual Studio Professional 2015 Update 1.
Here's what I've tried:
Error NU1002 The dependency T4MVCExtensions 3.16.5 in project WebApplication1 does not support framework DNXCore,Version=v5.0.
T4MVC.tt
, T4MVC.tt.hooks.t4
and T4MVC.tt.settings.xml
to the ASP.NET 5 solution: Visual Studio indeed offers to "Run Custom Tool" on the .tt file....... but running the transformation throws a NullReferenceException
:
Severity Code Description Project File Line Suppression State
Error Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.GetProjectItem(ProjectItems items, String subPath) in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 1398
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.GetProjectItem(Project project, String name) in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 1378
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.ProcessAreas(Project project) in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 600
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.PrepareDataToRender(TextTransformation tt) in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 557
at Microsoft.VisualStudio.TextTemplating3FE65EE761BB32C4AE5AEEB1949A6FC143551E0A56C74E6B36511A416E2DE40FB92F7CB1BC6FC7A97FF5B622AE39377BBFB9463480555898ADB8DD6D286C533D.GeneratedTextTransformation.TransformText() in c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt:line 40 WebApplication3 c:\dev\MyApp\WebApplication3\src\WebApplication3\T4MVC.tt 1398
Any other suggestions?
See also this related question about alternatives to T4MVC in ASP.NET 5.
As David Ebbo (hey!) pointed out, R4MVC - a side project was started a long time ago, but was stalled due to (at the time) breaking changes in the Roslyn compiler.
Luckily, the project was revived, and R4MVC has just released it's first alpha build, with more changes coming soon.
While the project works somewhat differently, and isn't using t4 templates, the end result is the same, and we're working to achieve feature parity with T4MVC in the near future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With