Entity Framework T4 Code Generator - Failed to allow include text for EF.Utility.CS.ttinclude

I am trying to automate the build process for a Silverlight 5 CI server using OpenRIA services.

I have a generated file created in the Entity Framework.edmx database from which DomainModel is generated, and as part of the assembly I want to generate entities using the T4 code generator.

Project settings

Changed my .csproj server.

Import

 <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:

Broken assembly

It looks correct, but there is such an error during assembly

 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 have T4 import

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

I have a suspicion that it targets a local directory, does not even create a directory.

I'm curious why the Microsoft.TextTemplating.targets variable 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 legal according to this path.

Perhaps I missed some settings, imports or a set of paths? How can I change or update the path for this utility?


Associated Q & A has already been verified:

+6
source share
2 answers

The problem can be solved by adding an absolute or relative path to EF.Utility.CS.ttinclude in your T4 file. For a build server, the best solution is probably to copy files, which can usually be found in the 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"#> 

eg:

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

For some reason, when a template conversion is started from MSBuild, it searches for .ttinclude files in the same location as the .tt file.

+2
source

I found that I was able to save the include file as

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

adding the following to my configuration

  <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </configSections> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="mssqllocaldb" /> </parameters> </defaultConnectionFactory> <connectionStrings> 
0
source

Source: https://habr.com/ru/post/989999/


All Articles