This project is read-only.


T4MVC can only execute through the Visual Studio host


Admittedly, I have just started working with T4 so I am not up to expert level.

I do not get this error if I take a stock MVC3 app, and simply drop and into the root project folder.
However, if I modify my project by adding the following line;
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets" />
I get the following error;
Error 24 Running transformation: System.Exception: T4MVC can only execute through the Visual Studio host
at Microsoft.VisualStudio.TextTemplating7EA676658956270405035C16AABD3C42.GeneratedTextTransformation.PrepareDataToRender(TextTransformation tt) in h:\work\MyT4MVCApp\src\MyT4MVCApp\ 616
at Microsoft.VisualStudio.TextTemplating7EA676658956270405035C16AABD3C42.GeneratedTextTransformation.TransformText() in h:\work\MyT4MVCApp\src\MyT4MVCApp\ 522
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result). Line=0, Column=0 MyT4MVCApp

I have found some problems with adding the
  1. I can no longer use macros in my TT file. i.e. <#@ include file="$(SolutionDir)..\sdk\tt\GeneratedByTool.ttinclude" #> no longer works.
  2. If I don't add, then my T4ParameterValues don't get into my host. i.e.
    <T4ParameterValues Include="RemoteMachine">
    <Value>TEST REMOTE MACHINE</Value>
    so the following returns an empty string if is not in my project.
    RemoteMachine:[<#=this.Host.ResolveParameterValue("-", "-", "RemoteMachine") #>]
needless to say it is getting frustrating...
Closed Apr 12, 2012 at 11:34 PM by davidebbo


davidebbo wrote Jan 30, 2012 at 4:06 PM

See which sounds similar. Generally, because T4MVC relies heavily on the VS DTE, it would be very hard for it to run at build time.