T4无法引用自己项目的程序集

时间:2018-02-24 05:14:23

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

在T4中,我只是想参考我自己的项目组装。根据在线说明,我尝试了以下内容:

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

接下来是:

<#@ import namespace="LazyDeploy" #>

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

Project

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\'.

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

1 个答案:

答案 0 :(得分:0)

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

<#@ assembly name="$(TargetDir)LazyDeploy.dll" #>
相关问题