Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

T4 code generator for Entity Framework - Failed to resolve include text for EF.Utility.CS.ttinclude

I'm trying to automate build process for CI server of Silverlight 5 application using OpenRIA Services.

I've got database-first Entity Framework .edmx generated file from which DomainModel is generated, and as part of build I want to generate entities by T4 code generator.

Project settings

My server .csproj changes.

Imports

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
# Microsoft.TextTemplating.targets are added after CSharp.targets
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v12.0\TextTemplating\Microsoft.TextTemplating.targets"/>

and properties

<PropertyGroup>
    <TransformOnBuild>true</TransformOnBuild>
    ...
<PropertyGroup>

Installed sdk, and tools:

  • Microsoft Visual Studio 2013 SDK
  • Microsoft Visual Studio 2013 Visualization & Modeling SDK
  • Entity Framework 6 Tools for Visual Studio 2012 & 2013

Broken build

Looks correct, but at build there is such a error

5>  Transforming template DomainModel\EntityConverters.tt...
5>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error : Failed to resolve include text for file:C:\{path to my project}\DomainModel\EF.Utility.CS.ttinclude. Line=-1, Column=-1
5>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TextTemplating\Microsoft.TextTemplating.targets(396,5): error : Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string. The transformation will not be run. . Line=21, Column=4

Suspicious

All .tt files has T4 import

<#@ include file="EF.Utility.CS.ttinclude"#> 

I have a suspicion that it's targeting local directory, not even build directory.

I'm curious why Microsoft.TextTemplating.targets variable is targeting EF.Utility.CS.ttinclude in {path to my project} not in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes where it really is. Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string seems legit according to this path.

Maybe I've missed some setting, import or path set? How I can change or update path for this utility?


Associated Q&A already checked:

  • Transforming T4 Templates On Build by Nico Ploner
  • How can I resolve this error: Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string - install/reinstall of Entity Framework 6 Tool for VS didn't worked
  • Silverlight 4, RIA Services & TFS 2010 Build Server - it's not this problem, my projects are building in correct order
  • TFS Hosted Build Controller - Microsoft.TextTemplating.targets not found - (for others) that was also a problem, if you're handling T4 automation build it could be usefull
like image 643
michalczukm Avatar asked Jun 30 '15 09:06

michalczukm


1 Answers

Problem can be solved by adding absolute or relative path to EF.Utility.CS.ttinclude in your T4 file. For build server the best solution is probably to copy files that usualy can be found in path C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes to your project and then change the line:

<#@ include file="EF.Utility.CS.ttinclude"#>

to for example:

<#@ include file="..\..\EF.Utility.CS.ttinclude"#>

For some reason when template transformation is run from MSBuild it looks for .ttinclude files in the same location that .tt file is.

like image 122
rotman Avatar answered Nov 01 '22 00:11

rotman