根据最新的评论这个线程,.TT模板将现在毕竟可以在ASP.NET 5开始支持Visual Studio的更新1.
哪个恕我直言会很好,因为在使用T4MVC多年后,我当然不想回到使用魔术字符串作为路由/视图名称(容易出错且不重构友好).
但是,我无法使用ASP.NET 5 RC和Visual Studio Professional 2015 Update 1.
这是我尝试过的:
将T4MVC NuGet(3.16.5)添加到空白的ASP.NET 5解决方案:nope,CoreCLR抱怨并且没有.tt文件添加到项目中:
错误NU1002项目WebApplication1中的依赖关系T4MVCExtensions 3.16.5不支持框架DNXCore,Version = v5.0.
在的NuGet添加到经典的ASP.NET 4.6的解决方案和手动复制了T4MVC.tt
,T4MVC.tt.hooks.t4
并T4MVC.tt.settings.xml
给ASP.NET 5解决方法:Visual Studio中的.TT文件确实提供了"运行自定义工具" ....
...但是运行转换会抛出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
还有其他建议吗?
另请参见本关于ASP.NET 5替代T4MVC相关的问题.