Cannot reference dependency assemblies in T4 template when using TransformOnBuild

后端 未结 4 824
忘掉有多难
忘掉有多难 2021-01-15 04:20

We\'re trying to use T4 with Visual Studio 2010 (SP1) to build scripts for another language that are based upon some of our existing C# classes. I\'m hoping for the followin

4条回答
  •  -上瘾入骨i
    2021-01-15 04:59

    If you want to reference dependency assemblies within a T4 script using macros and have text templating succeed during build-time, then you have to use project properties.

    Within your project:

      
      
        $(ProjectDir)
      
      
       
        $(T4ProjectDir)
        false
       
      
    

    Where the path to your text templating environment may be different.

    Then use $(T4ProjectDir) as you would use any other macro in your text template.

    Or you could also simply refer to existing properties:

      
       
        $(ProjectDir)
        false
       
      
    

提交回复
热议问题