Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > No resolution found yet :-( Recipie Exception: System.IO.FileNotFoundException. Recipie unable to find the included files.
 

No resolution found yet :-( Recipie Exception: System.IO.FileNotFoundException. Recipie unable to find the included files.

Hi

I have added a .txt file to include it in the t4 template.

But when am creating the Solution from this package, It's not able find the file and the following Exception was thrown:
System.IO.FileNotFoundException: Could not find file 'C:\Program Files\MyPackageGuidanceSetup\IncludedFile.txt'.

Its looking for this file where the package is installed under ProgramFiles\MyPackage\MyPackageSetup\ Generally we have the MyGudance.xml. But IncludedFile.txt' is under ProgramFiles\MyPackage\MyPackageSetup\Templates\Text\

How can we make sure that the Recipie reads the file from ProgramFiles\MyPackage\MyPackageSetup\Templates\Text\ instead of 'C:\Program Files\MyPackageGuidanceSetup\

radenb  Monday, March 03, 2008 1:22 PM
Hi N-Archer,

What are you using to run the T4 template? an T4Action or T4UnfoldAction?
The gax t4 host is resolving the include files using a given directory (that's the same as it's using to resolve the referenced assemblies), so if you're using one of the builtin actions, those actions are using the guidance package configuration base path, so in this case should be work. But if you're invoking the T4 template host directly, you should specify the binPath which is the path in where the includes and assemblies will be resolved.

hth.
jose
Jose Escrich  Tuesday, March 11, 2008 7:24 PM
Hi again,

You've wrong the path to the include file, it should be
<#@ include file="Templates\Text\IncludedFile.txt" #> than <#@ include file="IncludedFile.txt" #>

hth
jose.
Jose Escrich  Wednesday, March 12, 2008 4:22 PM

Who is throwing that exception? Are you using one of the built-in T4 transformation actions? Or is it your own code who's trying to open this file?


vga  Thursday, March 06, 2008 2:41 AM

The exception is thrown by the GAT package (eventually t4 engine) that I created which adds a .cs file from the T4 template that uses the included file.

Let me explain the scenerio again I am writing a T4 template which looks like following.

This T4 template is reading the content of the file and emits the text. However it's (the T4t emplaete engine) not able to locate the file because looking for the include file at other location where generally we have the GAT xml config files where we install the developed Package. So If I manyally copy this include file at this location it works but we can;t use this work around because package istallation should take care of this or T4 engine should read the file form the location where it is added.

Code Snippet

namespace <#= this.TargetNamespace #>

{

internal sealed class <#= this.NodeName #> : ConfigurationNode

{

<#

for(int i = 1; i <= 3; i++)

{

#>

<#=GetProperties()#>

<#=SayHello()#> // This method is written in IncludedFile.txt

<#

}

#>

}

}

<#@ include file="IncludedFile.txt" #> // This file exists under Templates/Text where this T4 template class is also there

<#+

public static string GetProperties()

{

StringBuilder sb = new StringBuilder();

sb.AppendLine("\tprivate string _firstName;");

sb.AppendLine("\tpublic string FirstName");

sb.AppendLine("\t{");

sb.AppendLine("\t get { return _firstName;}");

sb.AppendLine("\t set { _firstName = value;}");

sb.AppendLine("\t}");

return sb.ToString();

}

#>

radenb  Thursday, March 06, 2008 4:51 AM
Hi N-Archer,

What are you using to run the T4 template? an T4Action or T4UnfoldAction?
The gax t4 host is resolving the include files using a given directory (that's the same as it's using to resolve the referenced assemblies), so if you're using one of the builtin actions, those actions are using the guidance package configuration base path, so in this case should be work. But if you're invoking the T4 template host directly, you should specify the binPath which is the path in where the includes and assemblies will be resolved.

hth.
jose
Jose Escrich  Tuesday, March 11, 2008 7:24 PM

Jose,

I am not using anything customised to run the T4 template other than the "Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction" that generates the T4 output.

I am surprised that no one in this thread has answer to this or have faced this kind of issue.

The Action looks as follows

Code Snippet

<Actions>

<Action Name="GenerateClass" Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"

Template="Text\ConfigurationNode.cs.t4" >

<Input Name="TargetNamespace" RecipeArgument="TargetNamespace" />

<Input Name="NodeName" RecipeArgument="NodeName" />

<Output Name="Content" />

</Action>

<Action Name="AddClass" Type="Microsoft.Practices.RecipeFramework.Library.Actions.AddItemFromStringAction, Microsoft.Practices.RecipeFramework.Library"

Open="true">

<Input Name="Content" ActionOutput="GenerateClass.Content" />

<Input Name="TargetFileName" RecipeArgument="TargetFile" />

<Input Name="Project" RecipeArgument="CurrentProject" />

</Action>

</Actions>

radenb  Wednesday, March 12, 2008 5:14 AM
Hi again,

You've wrong the path to the include file, it should be
<#@ include file="Templates\Text\IncludedFile.txt" #> than <#@ include file="IncludedFile.txt" #>

hth
jose.
Jose Escrich  Wednesday, March 12, 2008 4:22 PM

Thanks Jose it worked.

radenb  Thursday, March 13, 2008 5:35 AM

You can use google to search for other answers

Custom Search

More Threads

• Database Project template
• System.Web.Extensions
• Programatically Executing a recipe while changing an input argument
• Possible Syntax for CommandBar Name Attribute
• Wizard data not replacing arguments correctly?
• GAT July 2007 Cannot Find ENVDTE
• Smart Client Software Factory (Recipe Framework Error) during Enable and Disable Packages
• Creating unbound reference to project template
• Unable to update Guidance Automation Extensions to new version
• The file cannot be opened with the selected editor