IT:AD:T4:HowTo:Resolve the Path to Project Files
Summary
A common use for T4 is referencing a source xml or Excel file in the project.
Process
The t4 has to have a template directive, with hostspecific set to true:
<#@ template debug="false" hostspecific="true" language="C#" #>
Then you can refer to a file in the app:
<#
//often stated as the solution, but it didn't work for me (came out as c:\Data\Exce\...)
//string fileName = Host.ResolvePath("\\Data\\Excel\\Resources.xlsx");
string fileName = Host.ResolveAssemblyReference("$(ProjectDir)") + "\\Data\\Excel\\Resources.xlsx";
#>