This project has moved. For the latest updates, please go here.


Error when T4 Templates set to transform on every build - VS2010


I have been getting an error with the L2ST4 templates in VS2010 when the following are added to a csproj file:
These should force all T4 templates in the project to be transformed on every compile, not just when the T4 template or related files are updated.
The following are the messages from the output window in VS:
Transforming template
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets(396,5): error : Running transformation: System.ArgumentNullException: Value cannot be null.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets(396,5): error : Parameter name: Could not obtain DTE from host
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets(396,5): error : at Microsoft.VisualStudio.TextTemplating6A33BEE2DA2D5E51284C36F80D152A12.GeneratedTextTransformation.VSManagementStrategy..ctor(ITextTemplatingEngineHost host)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets(396,5): error : at Microsoft.VisualStudio.TextTemplating6A33BEE2DA2D5E51284C36F80D152A12.GeneratedTextTransformation.ManagementStrategy.Create(ITextTemplatingEngineHost host)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets(396,5): error : at Microsoft.VisualStudio.TextTemplating6A33BEE2DA2D5E51284C36F80D152A12.GeneratedTextTransformation.Manager..ctor(ITextTemplatingEngineHost host, StringBuilder template, Boolean commonHeader)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets(396,5): error : at Microsoft.VisualStudio.TextTemplating6A33BEE2DA2D5E51284C36F80D152A12.GeneratedTextTransformation.TransformText()
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets(396,5): error : at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result). Line=0, Column=0
The issue appears to be with the ManagementStrategy and VSManagementStrategy in the l2st4.ttinclude file. I have attached a brute force patch that uses a simple try...catch to get around the issue but this should probably have a more elegant solution included in the next release.

file attachments

Closed Mar 27, 2013 at 4:21 PM by damieng


damieng wrote Dec 8, 2010 at 11:42 PM

I think the problem here is that it then happens inside the command line build process and no longer has access to the csproj file.

That means if new files have been added or removed the solution file can't be updated to reflect this and you'll get compile errors...