代码之家  ›  专栏  ›  技术社区  ›  brianc

在Visual Studio中获取生成的代码的文件路径?

  •  1
  • brianc  · 技术社区  · 15 年前

    在Visual Studio中使用代码生成模板时,是否可以在“自定义工具”运行时获取.tt文件的当前位置?假设我的自定义模板位于

    C:\projects\something\template.tt

    当它变魔术的时候,有没有办法返回上面的路径?

    <#=PathOfCurrentTTFile #>
    

    (所以pathofcurrenttfile==c:\projects\something\template.tt)

    1 回复  |  直到 15 年前
        1
  •  3
  •   Peter Lillevold Rene    15 年前

    看一看 this article . 有一些使用 Host.TemplateFile 这可能是你想要的。