it:ad:t4:howto:resolve_the_path_to_project_files

IT:AD:T4:HowTo:Resolve the Path to Project Files

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";
#>

  • /home/skysigal/public_html/data/pages/it/ad/t4/howto/resolve_the_path_to_project_files.txt
  • Last modified: 2023/11/04 01:59
  • by 127.0.0.1