Get Project or Relative Directory with T4

前端 未结 2 1232
北海茫月
北海茫月 2021-01-30 20:51

How can I get a reference to the directory of the visual studio project or solution or the directory of the t4 template from within a t4 template?

I have a template that

相关标签:
2条回答
  • 2021-01-30 20:59

    See The Host Specific Parameter section HERE.

    This snippet shows how to get the full path of src relative to the template.

    <#@ template hostspecific="true" #>
    // The location of the src folder relative to the t4 template:
    // <#= Host.ResolvePath("src") #>
    
    0 讨论(0)
  • 2021-01-30 21:08

    You can grab the path like this aswell

    <#@ template hostspecific="true" #>
    <#= Path.GetDirectoryName(this.Host.TemplateFile) #>
    
    0 讨论(0)
提交回复
热议问题