Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Error when using t4
 

Error when using t4

Hi all,
When i try to unfold a .tt (placed in a vs template) file with gat or when i use theTextTemplateAction to execute the t4 file i get the following error:

Error: 0 : Microsoft.Practices.RecipeFramework.ActionExecutionException: An exception occurred during the binding of reference or execution of recipe CreateDataLayerLibrary. Error was: Action GenerateDataLayer failed to execute:

Could not find a part of the path 'D:\Dev\GSL\SoftwareFactory\Trunk\GAT\RAD\Package\GSL.SoftwareFactory.GAT.Package\bin\Debug\Templates\SQL\StoredProceduresGenerator.tt'..

You can remove the reference to this recipe through the Guidance Package Manager. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\Dev\GSL\SoftwareFactory\Trunk\GAT\RAD\Package\GSL.SoftwareFactory.GAT.Package\bin\Debug\Templates\SQL\StoredProceduresGenerator.tt'.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)

at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)

at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)

at System.IO.StreamReader..ctor(String path, Encoding encoding)

at System.IO.File.ReadAllText(String path, Encoding encoding)

at Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction.Execute()

at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName, Dictionary`2 inputValues)

at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName)

at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionCoordinationService.Run(Dictionary`2 declaredActions, XmlElement coordinationData)

at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)

--- End of inner exception stack trace ---

at Microsoft.Practices.RecipeFramework.Recipe.UndoExecutedActionsAndRethrow(Exception ex)

at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)

at Microsoft.Practices.RecipeFramework.Recipe.Execute(Boolean allowSuspend)

at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(String recipe, IAssetReference reference, IDictionary arguments)

at Microsoft.Practices.RecipeFramework.GuidancePackage.ExecuteFromTemplate(String recipe, IDictionary arguments)

at Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate.ExecuteRecipe(Boolean executeActions)

at Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate.RunFinished()


So it search the t4 file in my debug folder but there is no place i specified this folder.

When i try it with an action i do it this way:

<Action Name="GenerateDataLayer"

Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"

Template="SQL\StoredProceduresGenerator.tt">

</Action>

The parent folder of the SQL folder is added to the registry.

When i use a vs template, i get this error, still the t4 file is placed in the unfolded project and when i run the t4 file, it generates the code without problems.

Someone who knows the solution for this?
Thx in advance
Glenn

Glenn_s  Friday, December 12, 2008 8:56 AM
Hi Glenn,

You should set the Copy to Output property of the tt file as "Copy if newer", so with it, the file will be copied into the output folder. Note that if your template is using <#includes#> you also have to set the Copy Output property for those files.

Jose Escrich - weblogs.asp.net/jescrich
  • Proposed As Answer byJose Escrich Monday, December 15, 2008 2:58 AM
  •  
Jose Escrich  Monday, December 15, 2008 2:58 AM
Thx for the reply.

After unfolding a templateproject i can usethe .tt files so they are on the correct location. But somewhere in the unfolding process or theTextTemplateAction , he search those .tt file in the debug folder(of the project where i'm developping the gat project) and gives this error.
Glenn_s  Monday, December 15, 2008 8:31 AM
Hi Glenn

TheTextTemplateAction will try to find the templates files in your guidance package output folder, which is the Debug one. So that's the expected behavior, If I followed you, you're unfolding those templates in your product project but the TextTemplateAction works with the GP context and it's trying to find those assets into the private GP folder.

If you want to run templates located in your product package (that's the project after unfolding a GP) you have to rewrite your own TextTemplateAction to change the probing mechanism or use the VS2008TextTemplatingFileGenerator custom tool.

Implement your own TextTemplateAction should be pretty straight forward, you have to write your custom implementation and inheriting from the T4Action base class then implement the Execute method. The main lines are:


On this case template is the full path to the tt file, the TextTemplateAction uses the GP manifest configuration path as a base path.

hope it helps
jose.

Jose Escrich - weblogs.asp.net/jescrich
  • Proposed As Answer byJose Escrich Monday, December 15, 2008 4:19 PM
  •  
Jose Escrich  Monday, December 15, 2008 4:18 PM
Hi,
i 'll give it a try but if i read the Gat doc:

TextTemplateAction

This action is used to unfold a template to a string, and is usually used in conjunction with AddItemFromStringAction, which is described in the next section. The action unfolds a T4 template and returns the result as a string in the output property named Content. It has one input property, Template, which is the path to the template file.

i don't understand why to specify a path when it always search in the outputfolder.
Also i don't thought i could register folders with .tt files inHKLM\Software\Microsoft\VisualStudio\9.0\TextTemplating\IncludeFolders\.tt

But i will give it a try...



Glenn_s  Tuesday, December 16, 2008 8:09 AM
Ok, maybe "Template, which is the path to the template file." is not enough clear. Regarding the registry key that you mentionHKLM\Software\Microsoft\VisualStudio\9.0\TextTemplating\IncludeFolders\.tt that's used by the VS Transformation Host (which is basically the custom tool that I'm already mention). That host will try to find out the *included* templates on those locations.

The GAX host has a different behavior because it was made in a top of previous version of tt and is not using that registry key to resolve the path of the included tt files.

hth
jose.

Jose Escrich - weblogs.asp.net/jescrich
  • Proposed As Answer byJose Escrich Tuesday, December 16, 2008 1:39 PM
  •  
Jose Escrich  Tuesday, December 16, 2008 1:38 PM

You can use google to search for other answers

Custom Search

More Threads

• Changes to the ProjectName from a Wizard is ignored
• Installing GAT, GAX, Microsoft Recipe Framework and MCSF
• System.InvalidOperationException: Cannot find registration information for template
• Database Project template
• Installed GAT/GAX but "Guidance Package" items not in VS08's menus
• Reality Check?
• Smart Client Development - problem whit context menu i VS2005
• Can't download GAT
• DAL
• Get to properties when expanding templates Is there a way