【问题标题】:T4 can't reference own project's assemblyT4 不能引用自己项目的程序集
【发布时间】:2018-02-24 05:14:23
【问题描述】:

在 T4 中,我只想引用我自己项目的程序集。按照网上的说明,我尝试了以下方法:

<#@ assembly name="$(TargetDir)" #>

接着是:

<#@ import namespace="LazyDeploy" #>

供您参考,这是我的解决方案结构:

除了HTMLFactory 命名空间之外,所有内容都在LazyDeploy 命名空间范围内。我还尝试将模板放入解决方案的根目录,但无济于事。错误如下:

An exception was thrown while trying to compile the transformation code. The following Exception was thrown:
System.IO.FileNotFoundException: Could not find a part of the path 'c:\users\kmalton\documents\visual studio 2017\Projects\LazyDeploy\LazyDeploy\bin\Debug\'.
File name: 'c:\users\kmalton\documents\visual studio 2017\Projects\LazyDeploy\LazyDeploy\bin\Debug\' ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\users\kmalton\documents\visual studio 2017\Projects\LazyDeploy\LazyDeploy\bin\Debug\'.

我不确定为什么会出现这种情况,因为目录存在,即我可以直接从堆栈跟踪剪切并粘贴到资源管理器中并在那里导航。

【问题讨论】:

    标签: visual-studio visual-studio-2017 .net-assembly t4


    【解决方案1】:

    解决方案是直接引用 dll 作为程序集声明的一部分:

    <#@ assembly name="$(TargetDir)LazyDeploy.dll" #>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多